这是我的活动的XML文件。使Android活动适合所有屏幕尺寸
如何让这适合所有屏幕尺寸,而不会出现图像按钮变得混乱!
我正在使用相对布局,我应该使用线性布局而不是?
以下是我的代码。
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context=".MainActivity"
android:background="@drawable/good">
<ImageButton
android:id="@+id/ImageButton03"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/imageButton1"
android:layout_alignTop="@+id/ImageButton01"
android:background="@drawable/btn_blue"
android:src="@drawable/plus"
android:onClick="NewCategory"/>
<ImageButton
android:id="@+id/ImageButton01"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/ImageButton02"
android:layout_below="@+id/ImageButton02"
android:layout_marginTop="29dp"
android:background="@drawable/btn_blue"
android:src="@drawable/plus"
android:onClick="NewItem" />
<ImageButton
android:id="@+id/ImageButton04"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="@+id/ImageButton01"
android:layout_alignLeft="@+id/ImageButton03"
android:background="@drawable/btn_blue"
android:src="@drawable/call" />
<Button
android:id="@+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:text="سـوبر ماركت التنـور"
android:textSize="40dp"
android:background="@drawable/btn_red"
android:textColor="@color/white" />
<ImageButton
android:id="@+id/imageButton1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignRight="@+id/button1"
android:layout_below="@+id/button1"
android:layout_marginTop="24dp"
android:background="@drawable/btn_blue"
android:onClick="ViewAllCategories"
android:src="@drawable/cart" />
<ImageButton
android:id="@+id/ImageButton05"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="@+id/ImageButton02"
android:layout_alignLeft="@+id/button1"
android:background="@drawable/btn_blue"
android:onClick="CreateNewUserAccount"
android:src="@drawable/user" />
<ImageButton
android:id="@+id/ImageButton02"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/ImageButton05"
android:layout_below="@+id/imageButton1"
android:layout_marginTop="33dp"
android:background="@drawable/btn_blue"
android:onClick="joinfacebook"
android:src="@drawable/f" />
这取决于你正在寻找的输出。你可以为你想要的最终屏幕放置一个屏幕截图。 –
如果这些都来自.xml。你不关闭RelativeLayout! – Umitk
定义“搞砸”。 – davidcesarino