Android 有没有办法让文本、按钮、进度条以任何分辨率停留在同一区域

Android 有没有办法让文本、按钮、进度条以任何分辨率停留在同一区域,android,android-layout,textview,imagebutton,android-xml,Android,Android Layout,Textview,Imagebutton,Android Xml,有没有办法使文本、按钮、进度条以任何分辨率停留在同一区域内。因此,如果你在Nexus10和Nexus7上,文本、按钮、进度条将显示在相同的位置。因为我的应用在Nexus10上看起来很傻。以下是我的xml代码: <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="m

有没有办法使文本、按钮、进度条以任何分辨率停留在同一区域内。因此,如果你在Nexus10和Nexus7上,文本、按钮、进度条将显示在相同的位置。因为我的应用在Nexus10上看起来很傻。以下是我的xml代码:

 <?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/background"
android:orientation="vertical" >

<TextView
    android:id="@+id/textView1"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="Next"
    android:textSize="20dp" 
    android:layout_marginTop="40dp"
    android:layout_marginLeft="20dp"
    android:layout_marginRight="20dp"
    android:gravity="center"
    android:textStyle="bold"
    android:textColor="#FFFFFF"/>

<ProgressBar
    android:id="@+id/progressBar"
    style="?android:attr/progressBarStyleHorizontal"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:layout_gravity="center"
    android:layout_marginTop="150dp"
    android:layout_marginRight="20dp"
    android:layout_marginLeft="20dp" />

<ImageButton
    android:id="@+id/pauseicon"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:src="@drawable/pauseicon" 
    android:layout_gravity="center"
    android:layout_marginTop="20dp"
    style="?android:attr/borderlessButtonStyle"/>

我不建议你像以前那样写布局。要使你的应用程序在不同的设备上看起来相似,你应该对齐所有视图,使它们相互关联

有很多信息

我还建议您使用线性布局,而不是线性布局,因为这样更容易使视图相互关联,这通常会使您的应用程序在不同的屏幕大小下看起来更好

下面是一个来自dev文档的相对布局示例

<EditText
    android:id="@+id/name"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:hint="@string/reminder" />
<Spinner
    android:id="@+id/dates"
    android:layout_width="0dp"
    android:layout_height="wrap_content"
    android:layout_below="@id/name"
    android:layout_alignParentLeft="true"
    android:layout_toLeftOf="@+id/times" />
<Spinner
    android:id="@id/times"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_below="@id/name"
    android:layout_alignParentRight="true" />
<Button
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_below="@id/times"
    android:layout_alignParentRight="true"
    android:text="@string/done" />

您能举个例子吗?@user2407147-完成-您应该更改布局以包含更多的alignParent。。。。以及……的左/右。。。。这有点烦人,这意味着你不能总是按照你想要的方式设计布局,但要支持多种屏幕尺寸,这是一个很好的选择