android - Create image layout -
i developing application. need as, want create layout shown in figure :

in this, took relative layout had given image background. image not having red dot (buttons).
i placed red button image button @ fix position. when run on galaxy s2 looks fine , work fine too.
but when tested layout on lg optimus l3 e400. red buttons not on position set.
the code of layout :
<relativelayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="fill_parent" android:layout_height="fill_parent" android:background="@drawable/background" > <textview android:id="@+id/textview_navigationbar" android:layout_width="fill_parent" android:layout_height="wrap_content" android:background="@drawable/navigationbar" android:text="@string/string_map" android:gravity="center" android:textisselectable="false" /> <relativelayout android:layout_below="@+id/textview_navigationbar" android:layout_width="fill_parent" android:layout_height="fill_parent" android:layout_margintop="50sp" android:layout_marginbottom="50sp" android:background="@drawable/map"> <imagebutton android:id="@+id/imagebutton_1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_margintop="100dip" android:layout_marginleft="50dip" android:background="@drawable/button_1" /> <imagebutton android:id="@+id/imagebutton_2" android:layout_below="@+id/imagebutton_1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_margintop="30dip" android:layout_marginleft="6dip" android:background="@drawable/button_2" /> <imagebutton android:id="@+id/imagebutton_3" android:layout_below="@+id/imagebutton_2" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_margintop="1dip" android:layout_marginleft="40dip" android:background="@drawable/button_3" /> </relativelayout> </relativelayout> in lg optimus l3 e400 looks :

the red buttons not on position. don't want use map view don't know , never used it.
please guide me how move out of problem. how create layout maximum resolution , screen support.
the easiest way create custom view holds image (bitmap) , buttons on top of it, , use ondraw method draw buttons, , analyse coordinates on ontouch create touch events.
if maintain image's aspect ration (width:height) can map buttons suitable location using scaling.
here list of custom views examples:
you can use andengine 2d graphics/gaming engine android, , take care of scaling you.
take here : official website , examples
Comments
Post a Comment