有没有办法在水平线性布局中包装图像按钮?或者还有其他方法可以做以下事情吗?
我有六个图像按钮。假设这些按钮出现在这样的中等分辨率设备中:
Image button 1 | Image button 2 | Image button 3 | (1st row)
Image button 4 | Image button 5 | Image button 6 | (2nd row)
我希望这些按钮出现在平板电脑或任何这样的高分辨率设备中:
Image button 1 | Image button 2 | Image button 3 | Image button 4 | (1st row)
Image button 5 | Image button 6 | (2nd row)
或者像这样:
Image button 1 | Image button 2 | Image button 3 | Image button 4 | Image button 5 |
Image button 6 |
根据设备屏幕。
这是我的主要 XML 文件:
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@layout/back2">
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@layout/back2">
<TextView
android:layout_width="fill_parent"
android:layout_height="50dp"
android:background="@layout/button5"
android:gravity="center"
android:orientation="vertical"
android:text="@string/hello"
android:textColor="#D5D5D5"
android:textSize="20sp" />
<com.google.ads.AdView android:id="@+id/adView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
ads:adUnitId="a150c75f96c352c"
ads:adSize="BANNER"
ads:loadAdOnCreate="true"/>
<org.core.mywindows8.FlowLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:f="http://schemas.android.com/apk/res/org.core.mywindows8"
f:horizontalSpacing="6dip"
f:verticalSpacing="12dip"
f:fitContent="true"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@color/morange1"
android:drawableTop="@drawable/tutorials"
android:textColor="#ffffff"
android:id="@+id/button1"
android:paddingTop="16sp"
android:drawablePadding="10sp"
android:text="@string/tutorials"
/>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@color/mviolet"
android:drawableTop="@drawable/themes"
android:textColor="#ffffff"
android:id="@+id/button2"
android:paddingTop="16sp"
android:drawablePadding="10sp"
android:text="@string/themes"
/>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@color/mblu2"
android:drawableTop="@drawable/gadgets"
android:textColor="#ffffff"
android:id="@+id/button3"
android:paddingTop="16sp"
android:drawablePadding="10sp"
android:text="@string/gadgets"/>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@color/mgree"
android:drawableTop="@drawable/network"
android:textColor="#ffffff"
android:id="@+id/button4"
android:paddingTop="16sp"
android:drawablePadding="10sp"
android:text="@string/networking"/>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@color/mblu3"
android:drawableTop="@drawable/search"
android:textColor="#ffffff"
android:id="@+id/button5"
android:paddingTop="16sp"
android:drawablePadding="10sp"
android:text="@string/win8index"/>
</org.core.mywindows8.FlowLayout>
</LinearLayout>
</ScrollView>