Android'de bir Grid Düzeni oluşturmak için v7 destek kitaplığından Grid Düzeni kullanıyorum. Layout, Android stüdyosunda ekranları önizlemeden teyit ettiğim daha büyük ekranlı cihazlarda (ekran boyutları> 4 ") mükemmel bir görüntü oluşturur.Fakat, sadece ilk satır olmak üzere daha küçük ekran cihazlarında (gerçek bir cihazda da kontrol edilir) kötü bir şekilde bozulur. . görünür uç ekran kadar ekran aşağıdaki gibidir: (bu durumda Galaxy S) küçük bir ekran cihazı, bir daha büyük bir ekran cihazının üzerindeandroid.support.v7.widget.GridLayout küçük ekranlı cihazlarda bozuldu android
üzerinde
(5,1" bu durumda)
Bu konuda<android.support.v7.widget.GridLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#BDBDBD"
android:padding="3dp"
app:columnCount="3"
app:rowCount="2"
android:layout_below="@+id/pager"
android:layout_marginLeft="0dp"
>
<LinearLayout
app:layout_column="0"
app:layout_columnWeight="1"
app:layout_rowWeight="1"
android:layout_marginLeft="0dp"
android:background="#FFF"
android:layout_marginRight="2dp"
android:layout_marginBottom="2dp"
android:orientation="vertical"
android:gravity="center"
android:onClick="buttonActions"
android:id="@+id/menu1"
android:clickable="true"
app:layout_row="0"
>
<ImageButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/menu11"
android:background="#FFF"
android:layout_gravity="center"
android:id="@+id/menu1_img"
android:onClick="buttonActions"
/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/menu1"
android:gravity="center"
android:layout_gravity="center"
android:layout_marginTop="3dp"
android:id="@+id/menu1_txt"
android:onClick="buttonActions"
/>
</LinearLayout>
<LinearLayout
app:layout_column="1"
app:layout_columnWeight="1"
app:layout_rowWeight="1"
android:layout_marginLeft="0dp"
android:background="#FFF"
android:layout_marginRight="2dp"
android:layout_marginBottom="2dp"
android:orientation="vertical"
android:gravity="center"
android:id="@+id/menu2"
android:onClick="buttonActions"
app:layout_row="0"
>
<ImageButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/menu12"
android:background="#FFF"
android:layout_gravity="center"
android:id="@+id/menu2_img"
android:onClick="buttonActions"
/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/menu2"
android:gravity="center"
android:layout_gravity="center"
android:layout_marginTop="3dp"
android:id="@+id/menu2_txt"
android:onClick="buttonActions"
/>
</LinearLayout>
<LinearLayout
app:layout_column="2"
app:layout_columnWeight="1"
app:layout_rowWeight="1"
android:layout_marginLeft="0dp"
android:background="#FFF"
android:layout_marginRight="2dp"
android:layout_marginBottom="2dp"
android:orientation="vertical"
android:gravity="center"
android:onClick="buttonActions"
android:id="@+id/menu3"
app:layout_row="0"
>
<ImageButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/menu13"
android:background="#FFF"
android:layout_gravity="center"
android:onClick="buttonActions"
android:id="@+id/menu3_img"
/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/menu3"
android:gravity="center"
android:layout_gravity="center"
android:layout_marginTop="3dp"
android:onClick="buttonActions"
android:id="@+id/menu3_txt"
/>
</LinearLayout>
<LinearLayout
app:layout_column="0"
app:layout_columnWeight="1"
app:layout_rowWeight="1"
android:layout_marginLeft="0dp"
android:background="#FFF"
android:layout_marginRight="2dp"
android:layout_marginBottom="2dp"
android:orientation="vertical"
android:gravity="center"
android:id="@+id/menu4"
android:onClick="buttonActions"
>
<ImageButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/menu14"
android:background="#FFF"
android:layout_gravity="center"
android:id="@+id/menu4_img"
android:onClick="buttonActions"
/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/menu4"
android:gravity="center"
android:layout_gravity="center"
android:layout_marginTop="3dp"
android:id="@+id/menu4_txt"
android:onClick="buttonActions"
/>
</LinearLayout>
<LinearLayout
app:layout_column="1"
app:layout_columnWeight="1"
app:layout_rowWeight="1"
android:layout_marginLeft="0dp"
android:background="#FFF"
android:layout_marginRight="2dp"
android:layout_marginBottom="2dp"
android:orientation="vertical"
android:gravity="center"
android:id="@+id/menu5"
android:onClick="buttonActions"
>
<ImageButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/menu15"
android:background="#FFF"
android:layout_gravity="center"
android:id="@+id/menu5_img"
android:onClick="buttonActions"
/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/menu5"
android:gravity="center"
android:layout_gravity="center"
android:layout_marginTop="3dp"
android:id="@+id/menu5_txt"
android:onClick="buttonActions"
/>
</LinearLayout>
<LinearLayout
app:layout_column="2"
app:layout_columnWeight="1"
app:layout_rowWeight="1"
android:layout_marginLeft="0dp"
android:background="#FFF"
android:layout_marginRight="2dp"
android:layout_marginBottom="2dp"
android:orientation="vertical"
android:gravity="center"
android:onClick="buttonActions"
android:id="@+id/menu6"
>
<ImageButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/menu16"
android:background="#FFF"
android:layout_gravity="center"
android:onClick="buttonActions"
android:id="@+id/menu6_img"
/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/menu6"
android:gravity="center"
android:layout_gravity="center"
android:layout_marginTop="3dp"
android:onClick="buttonActions"
android:id="@+id/menu6_txt"
/>
</LinearLayout>
<LinearLayout
app:layout_column="0"
app:layout_columnWeight="1"
app:layout_rowWeight="1"
android:layout_marginLeft="0dp"
android:background="#FFF"
android:layout_marginRight="2dp"
android:layout_marginBottom="2dp"
android:orientation="vertical"
android:gravity="center"
android:id="@+id/menu7"
android:onClick="buttonActions"
>
<ImageButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/menu17"
android:background="#FFF"
android:layout_gravity="center"
android:id="@+id/menu7_img"
android:onClick="buttonActions"
/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/menu7"
android:gravity="center"
android:layout_gravity="center"
android:layout_marginTop="3dp"
android:onClick="buttonActions"
android:id="@+id/menu7_txt"
/>
</LinearLayout>
<LinearLayout
app:layout_column="1"
app:layout_columnWeight="1"
app:layout_rowWeight="1"
android:layout_marginLeft="0dp"
android:background="#FFF"
android:layout_marginRight="2dp"
android:layout_marginBottom="2dp"
android:orientation="vertical"
android:gravity="center"
android:onClick="buttonActions"
android:id="@+id/menu8"
>
<ImageButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/menu18"
android:background="#FFF"
android:layout_gravity="center"
android:onClick="buttonActions"
android:id="@+id/menu8_img"
/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/menu8"
android:gravity="center"
android:layout_gravity="center"
android:layout_marginTop="3dp"
android:onClick="buttonActions"
android:id="@+id/menu8_txt"
/>
</LinearLayout>
<LinearLayout
app:layout_column="2"
app:layout_columnWeight="1"
app:layout_rowWeight="1"
android:layout_marginLeft="0dp"
android:background="#FFF"
android:layout_marginRight="2dp"
android:layout_marginBottom="2dp"
android:orientation="vertical"
android:gravity="center"
android:onClick="buttonActions"
android:id="@+id/menu9"
>
<ImageButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/menu19"
android:background="#FFF"
android:layout_gravity="center"
android:onClick="buttonActions"
android:id="@+id/menu9_img"
/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/menu9"
android:gravity="center"
android:layout_gravity="center"
android:layout_marginTop="3dp"
android:onClick="buttonActions"
android:id="@+id/menu9_txt"
/>
</LinearLayout>
</android.support.v7.widget.GridLayout>
Yardım, küçük cihazlarda uyumluluk sorunu çözmek için mutluluk duyacağız:
Aşağıda aynı kodudur. Şimdiden teşekkürler.
Bu [GridLayout üzerinde blog yazısı] (http://android-developers.blogspot.com/2011/11/new bulabilir ağırlıklarla LinearLayouts kullanarak yaklaşımdır -layout-widgets-space-and-gridlayout.html) yardımcı olur. Veya GridLayout'u ortadan kaldırmanız ve [LinearLayout with heavy] (http://developer.android.com/guide/topics/ui/layout/linear.html#Weight) kullanmanız daha kolay olabilir. – tachyonflux
LinearLayout ile tüm çalışma düzenini, her cihazda ağırlıklar ve çalışmalarla elde ettik. Teşekkürler. –