如何确定屏幕大小与android中的所有android设备兼容?
我有一个带按钮的应用程序。按钮样式是xml渐变。在3.2 QVGA模拟器中运行此应用程序时,窗口小部件会像这样从外部进入视图 模拟器屏幕截图: 在5英寸显示器上运行时,我可以看到完整的视图 设备屏幕截图: 如何通过支持所有屏幕大小的兼容性来解决此问题如何确定屏幕大小与android中的所有android设备兼容?,android,size,screen,device,Android,Size,Screen,Device,我有一个带按钮的应用程序。按钮样式是xml渐变。在3.2 QVGA模拟器中运行此应用程序时,窗口小部件会像这样从外部进入视图 模拟器屏幕截图: 在5英寸显示器上运行时,我可以看到完整的视图 设备屏幕截图: 如何通过支持所有屏幕大小的兼容性来解决此问题 <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/to
<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:background="@drawable/background"
tools:context="${relativePackage}.${activityClass}" >
<LinearLayout
android:id="@+id/linearLayout4"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<RelativeLayout
android:id="@+id/linearLayout1"
android:layout_width="fill_parent"
android:layout_height="110dp"
android:layout_alignParentTop="true"
android:layout_marginTop="50dp"
android:orientation="horizontal" >
<Button
android:id="@+id/imageExpense"
android:layout_width="90dp"
android:layout_height="95dp"
android:layout_marginLeft="35dp"
android:layout_marginTop="5dp"
android:background="@drawable/add_btnstyle"
android:gravity="center|bottom"
android:padding="10dp"
android:text="Expense" />
<Button
android:id="@+id/imageIncome"
android:layout_width="90dp"
android:layout_height="95dp"
android:layout_alignParentRight="true"
android:layout_marginRight="40dp"
android:layout_marginTop="5dp"
android:background="@drawable/add_btnstyle"
android:gravity="center|bottom"
android:padding="10dp"
android:text="Income"
android:textAlignment="gravity" />
<ImageView
android:id="@+id/imageView1"
android:layout_width="60dp"
android:layout_height="65dp"
android:layout_alignLeft="@+id/imageExpense"
android:layout_alignParentTop="true"
android:layout_marginLeft="13dp"
android:layout_marginTop="12dp"
android:src="@drawable/expense" />
<ImageView
android:id="@+id/imageView2"
android:layout_width="50dp"
android:layout_height="50dp"
android:layout_alignRight="@+id/imageIncome"
android:layout_alignTop="@+id/imageView1"
android:layout_marginRight="20dp"
android:layout_marginTop="7dp"
android:src="@drawable/income" />
</RelativeLayout>
<RelativeLayout
android:id="@+id/linearLayout2"
android:layout_width="fill_parent"
android:layout_height="110dp"
android:layout_alignParentLeft="true"
android:layout_below="@+id/linearLayout1"
android:layout_marginTop="60dp"
android:orientation="horizontal" >
<Button
android:id="@+id/imageReport"
android:layout_width="90dp"
android:layout_height="95dp"
android:layout_marginLeft="35dp"
android:layout_marginRight="40dp"
android:layout_marginTop="5dp"
android:background="@drawable/add_btnstyle"
android:gravity="center|bottom"
android:padding="10dp"
android:text="Report" />
<ImageView
android:id="@+id/imageViewRep"
android:layout_width="45dp"
android:layout_height="45dp"
android:layout_marginLeft="57dp"
android:layout_marginTop="20dp"
android:src="@drawable/pie_chart" />
<Button
android:id="@+id/imageSettings"
android:layout_width="90dp"
android:layout_height="95dp"
android:layout_alignParentRight="true"
android:layout_marginRight="40dp"
android:layout_marginTop="5dp"
android:background="@drawable/add_btnstyle"
android:gravity="center|bottom"
android:padding="10dp"
android:text="Settings" />
<ImageView
android:id="@+id/imageView4"
android:layout_width="45dp"
android:layout_height="45dp"
android:layout_alignRight="@+id/imageSettings"
android:layout_alignTop="@+id/imageView3"
android:layout_marginRight="22dp"
android:layout_marginTop="20dp"
android:src="@drawable/system_config_services" />
</RelativeLayout>
</LinearLayout>
<LinearLayout
android:id="@+id/linearLayout3"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/linearLayout4"
android:layout_centerHorizontal="true"
android:layout_margin="20dp"
android:orientation="vertical"
android:padding="20dp" >
<Button
android:id="@+id/imageAbout"
android:layout_width="200dp"
android:layout_height="55dp"
android:layout_gravity="center_horizontal"
android:background="@drawable/settings_add_btnstyle"
android:text="Log Off" />
<TextView
android:id="@+id/txtLogo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginTop="20dp"
android:text="Powered by Microclouds India Pvt Ltd"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textSize="12sp"
android:textStyle="italic" />
</LinearLayout>
</RelativeLayout>
使用垂直
在上查找scrollview教程为不同的设备创建不同的布局:
res/layout/main_activity.xml # For phones
res/layout-sw600dp/main_activity.xml # For 7” tablets
res/layout-sw720dp/main_activity.xml # For 10” tablets
设备将根据设备大小自动加载相关布局。您只需浏览一下-我认为您的布局xml有问题…您可以发布布局xml吗?@HamidShatu在我的问题中添加了xml代码。。
res/layout/main_activity.xml # For phones
res/layout-sw600dp/main_activity.xml # For 7” tablets
res/layout-sw720dp/main_activity.xml # For 10” tablets