Java 如何使布局支持多屏幕大小(响应性)

Java 如何使布局支持多屏幕大小(响应性),java,android,xml,Java,Android,Xml,我的about页面使用以下代码,但内容会根据屏幕大小和方向而改变。请帮助这里是我的about页面代码 关于.xml 为不同的屏幕尺寸制作不同的布局。阅读第一部分。 您只需在res/中创建一个名为layout swdp的新文件夹,其中将替换为屏幕尺寸。例如,7英寸平板电脑将使用layout-sw600dp,10英寸平板电脑将使用layout-sw720dp,将布局复制到此处,并重新排列以使其响应 对于不同的方向,您可以将-land或-port放在布局文件夹的名称之后。我确信这是因为您使用的是相对布

我的about页面使用以下代码,但内容会根据屏幕大小和方向而改变。请帮助这里是我的about页面代码

关于.xml
为不同的屏幕尺寸制作不同的布局。阅读第一部分。
您只需在
res/
中创建一个名为
layout swdp
的新文件夹,其中将替换为屏幕尺寸。例如,7英寸平板电脑将使用
layout-sw600dp
,10英寸平板电脑将使用
layout-sw720dp
,将布局复制到此处,并重新排列以使其响应


对于不同的方向,您可以将
-land
-port
放在布局文件夹的名称之后。

我确信这是因为您使用的是相对布局,有时在使用它时,两个widget可以合并。尝试使用线性布局,如果这是您的问题,它应该可以解决您的问题。


<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="#493F0B" >

    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
         >

        <TextView
            android:id="@+id/tvAboutHeader"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:background="#F5F6D4"
            android:gravity="center"
            android:padding="10sp"
            android:text="@string/about_title"
            android:textAppearance="?android:attr/textAppearanceLarge" />

        <TextView
            android:id="@+id/tvabout1"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_alignParentLeft="true"
            android:layout_below="@+id/tvAboutHeader"
            android:layout_marginTop="8dp"
            android:background="#CDE855"
            android:padding="10sp"
            android:text="@string/about_info1"
            android:textAppearance="?android:attr/textAppearanceMedium" />

        <TextView
            android:id="@+id/tvabout2"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_alignParentLeft="true"
            android:layout_below="@+id/tvabout1"
            android:background="#ABC921"
            android:padding="10sp"
            android:text="@string/about_info2"
            android:textAppearance="?android:attr/textAppearanceMedium" />

        <TextView
            android:id="@+id/tvabout3"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_alignParentLeft="true"
            android:layout_below="@+id/tvabout2"
            android:background="#BEDB39"
            android:text="@string/about_info3"
            android:textAppearance="?android:attr/textAppearanceMedium" />
    </RelativeLayout>

</ScrollView>

试试这个

@NishalKulkarni这不是响应,但它是非响应的,这与你的问题相反。@jyoon我认为会起作用,因为它有相对布局和内容高度,可以随屏幕大小调整。
import android.app.Activity;
import android.os.Bundle;
public class About extends Activity{

@Override
public void onCreate(Bundle savedInstanceState) {
    // TODO Auto-generated method stub
    super.onCreate(savedInstanceState);
    setContentView(R.layout.about);
    
    }
}
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="#493F0B" >

    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
         >

        <TextView
            android:id="@+id/tvAboutHeader"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:background="#F5F6D4"
            android:gravity="center"
            android:padding="10sp"
            android:text="@string/about_title"
            android:textAppearance="?android:attr/textAppearanceLarge" />

        <TextView
            android:id="@+id/tvabout1"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_alignParentLeft="true"
            android:layout_below="@+id/tvAboutHeader"
            android:layout_marginTop="8dp"
            android:background="#CDE855"
            android:padding="10sp"
            android:text="@string/about_info1"
            android:textAppearance="?android:attr/textAppearanceMedium" />

        <TextView
            android:id="@+id/tvabout2"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_alignParentLeft="true"
            android:layout_below="@+id/tvabout1"
            android:background="#ABC921"
            android:padding="10sp"
            android:text="@string/about_info2"
            android:textAppearance="?android:attr/textAppearanceMedium" />

        <TextView
            android:id="@+id/tvabout3"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_alignParentLeft="true"
            android:layout_below="@+id/tvabout2"
            android:background="#BEDB39"
            android:text="@string/about_info3"
            android:textAppearance="?android:attr/textAppearanceMedium" />
    </RelativeLayout>

</ScrollView>