Android 使布局xml文件与平板电脑和移动电话兼容

Android 使布局xml文件与平板电脑和移动电话兼容,android,android-layout,Android,Android Layout,我已经构建了一个android应用程序。我希望我的布局xml文件能够兼容平板电脑和手机,从GUI的角度来看。我参考了链接 "http://developer.android.com/training/multiscreen/screensizes.html“供参考。谁能告诉我我的xml文件是否兼容。这是我的两个xml文件。 selection.xml <?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:and

我已经构建了一个android应用程序。我希望我的布局xml文件能够兼容平板电脑和手机,从GUI的角度来看。我参考了链接 "http://developer.android.com/training/multiscreen/screensizes.html“供参考。谁能告诉我我的xml文件是否兼容。这是我的两个xml文件。 selection.xml

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical" 
     android:background="@drawable/img7">
    <TextView
        android:id="@+id/textView1"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentLeft="true"
        android:layout_alignParentTop="true"
        android:textColor="#32cd32"
        android:text="Select Command"
        android:textStyle="bold"
       android:textSize="50sp"
        android:textAppearance="?android:attr/textAppearanceLarge" />
    <Button
        android:id="@+id/button1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentLeft="true"
        android:layout_below="@+id/textView1"
        android:layout_marginTop="5dp"
        android:drawableLeft="@drawable/unix"
        android:text="UNIX" 
        android:textSize="25sp"
        android:textColor="#FF0000"
        android:background="#8b8989"/>

    <Button
        android:id="@+id/button2"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentLeft="true"
        android:layout_below="@+id/button1"
        android:layout_marginTop="10dp"
        android:drawableLeft="@drawable/aix1"
        android:background="#8b8989"
        android:textSize="25sp"
        android:textColor="#FF0000"/>
    <Button
        android:id="@+id/button3"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentLeft="true"
        android:layout_below="@+id/button2"
        android:layout_marginTop="10dp"
        android:drawableLeft="@drawable/san1"
        android:background="#8b8989"
        android:textSize="25sp"
        android:textColor="#FF0000"/>
    <Button
        android:id="@+id/button4"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentLeft="true"
        android:layout_below="@+id/button3"
        android:layout_marginTop="10dp"
        android:drawableLeft="@drawable/database1"
        android:background="#8b8989"
        android:textSize="25sp"
        android:textColor="#FF0000"/>
    <Button
        android:id="@+id/button5"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentLeft="true"
        android:layout_below="@+id/button4"
        android:layout_marginTop="10dp"
        android:drawableLeft="@drawable/tsmlogo"
        android:text="TSM" 
        android:background="#8b8989"
        android:textSize="25sp"
        android:textColor="#FF0000"/>
    <TextView
        android:id="@+id/textView3"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:layout_centerHorizontal="true"
        android:text="Cympac Software Solutions Pvt Ltd"
        android:textAppearance="?android:attr/textAppearanceMedium"
        android:textColor="#228b22"
        android:background="#FFFFFF" 
        android:textStyle="bold"
        android:textSize="16sp"
        android:drawableLeft="@drawable/smallicon"/>


</RelativeLayout>

和unixxml.xml

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    android:background="@drawable/img7" >
     <Button
        android:id="@+id/button1"
        style="?android:attr/buttonStyleSmall"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentRight="true"
        android:layout_alignParentTop="true"
        android:text=""
        android:background="@drawable/house1" />
     <TextView
        android:id="@+id/textView1"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"

        android:layout_alignBottom="@+id/button1"
        android:layout_alignParentLeft="true"
        android:text="Enter UNIX Command"
        android:textColor="#FF0000" 
        android:textSize="25sp"
        />

    <AutoCompleteTextView
        android:id="@+id/autoCompleteTextView1"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentLeft="true"
        android:layout_alignParentRight="true"
        android:layout_below="@+id/textView1"
        android:layout_marginTop="14dp"
        android:ems="10"
        android:hint="Start Typing Here........"
        android:textColor="#FF0000" >

        <requestFocus />
    </AutoCompleteTextView>

    <Button
        android:id="@+id/button2"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentLeft="true"
        android:layout_below="@+id/autoCompleteTextView1"
        android:text="Get Meaning"

        android:drawableLeft="@drawable/searchpic1"
        android:textColor="#FF0000"
        android:textSize="20sp" />
    <ImageView
        android:id="@+id/imageView1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_below="@id/button2"

        android:src="@drawable/book1" />

    <TextView
        android:id="@+id/textView2"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentLeft="true"
        android:layout_below="@+id/imageView1"
        android:text=""
        android:textColor="#FF0000"
         />

    <TextView
        android:id="@+id/textView3"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:layout_centerHorizontal="true"
        android:text="Cympac Software Solutions Pvt Ltd"
        android:textAppearance="?android:attr/textAppearanceMedium"
        android:textColor="#228b22"
        android:background="#FFFFFF" 
        android:textStyle="bold"
        android:textSize="16sp"
        android:drawableLeft="@drawable/smallicon"/>



</RelativeLayout>


为什么不在目标模拟器上试用?使一个布局适合所有屏幕尺寸是不切实际的。如果您可以设计完全包含线性布局的布局而不使用其他布局,您可以同时使用它:)尝试和电话:)线性布局是我的建议Thanx我将尝试使用线性布局。