Android GridLayout fit for all size -
i'm porting ios app on android can't fit simple layout sizes:
the problem imagebutton
s don't scale. layout fit glove nexus 4
i put images in drawable-mdpi
gridlayout
must table webview
span 3 columns on top , 3x3 button images
<?xml version="1.0" encoding="utf-8"?> <gridlayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="wrap_content" android:layout_height="wrap_content" android:orientation="vertical" android:scaletype="center" android:usedefaultmargins="true" > <webview android:id="@+id/userwebview" android:layout_height="120dp" android:layout_column="1" android:layout_columnspan="3" android:layout_gravity="fill_horizontal" android:layout_row="0" /> <imagebutton android:id="@+id/btn1" android:layout_column="0" android:layout_columnspan="2" android:layout_row="1" android:background="@drawable/box_1" android:scaletype="fitcenter" /> <imagebutton android:id="@+id/btn2" android:layout_column="2" android:layout_row="1" android:background="@drawable/box_2" android:scaletype="fitcenter" /> <imagebutton android:id="@+id/btn3" android:layout_width="wrap_content" android:layout_column="3" android:layout_row="1" android:background="@drawable/box_3" android:scaletype="center" /> <imagebutton android:id="@+id/btn4" android:layout_column="0" android:layout_columnspan="2" android:layout_row="3" android:layout_rowspan="2" android:background="@drawable/box_4" android:scaletype="fitcenter" /> <imagebutton android:id="@+id/btn5" android:layout_column="2" android:layout_row="4" android:background="@drawable/box_5" android:scaletype="fitcenter" /> <imagebutton android:id="@+id/btn6" android:layout_width="wrap_content" android:layout_column="3" android:layout_row="4" android:background="@drawable/box_6" android:scaletype="fitcenter" /> <imagebutton android:id="@+id/btn7" android:layout_column="0" android:layout_columnspan="2" android:layout_row="6" android:layout_rowspan="2" android:background="@drawable/box_7" android:scaletype="fitcenter" /> <imagebutton android:id="@+id/btn8" android:layout_column="2" android:layout_gravity="left|bottom" android:layout_row="7" android:background="@drawable/box_8" android:scaletype="fitcenter" /> <imagebutton android:id="@+id/btn9" android:layout_column="3" android:layout_row="7" android:background="@drawable/box_9" android:scaletype="fitcenter" /> </gridlayout>
don't put images in drawable-mdpi
, put convenient ones other co-drawable folders drawable-hdpi
, drawable-xhdpi
etc. or create new folder named drawable
, no prefix or suffix, , put images it
Comments
Post a Comment