Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/google-chrome/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 如何让内容填满整个屏幕?_Android - Fatal编程技术网

Android 如何让内容填满整个屏幕?

Android 如何让内容填满整个屏幕?,android,Android,如何使内容填充整个屏幕而不考虑屏幕大小 图片如下。 我希望它看起来像左图,而不是右图: 如果使用RelativeLayout,您可以将容器更改为LinearLayout,并将布局重量设置为其子项: <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout

如何使内容填充整个屏幕而不考虑屏幕大小

图片如下。 我希望它看起来像左图,而不是右图:


如果使用RelativeLayout,您可以将容器更改为LinearLayout,并将布局重量设置为其子项:

 <LinearLayout
        xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical">

    <TextView
            android:layout_width="wrap_content"
            android:layout_height="0dp"
            android:layout_weight="1"
            android:text="Text 1"/>

    <TextView
            android:layout_width="wrap_content"
            android:layout_height="0dp"
            android:layout_weight="1"
            android:text="Text 2"/>

</LinearLayout>

让我们考虑一下你的XML文件

创建内部RelativeLayout并将其宽度和高度设置为与父项匹配

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
   android:layout_width="match_parent"
   android:layout_height="match_parent"
   android:paddingLeft="16dp"
   android:paddingRight="16dp" >
<!-- here you create your RelativeLayout -->
<RelativeLayout 
   android:layout_width="match_parent"
   android:layout_height="match_parent"
    >

   <EditText
      android:id="@+id/name"
      android:layout_width="fill_parent"
      android:layout_height="wrap_content"
      android:hint="@string/reminder" />
   <TextView
      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" />
   <TextView
      android:id="@id/times"
      android:layout_width="96dp"
      android:layout_height="wrap_content"
      android:layout_below="@id/name"
      android:layout_alignParentRight="true" />
   <Button
      android:layout_width="96dp"
      android:layout_height="wrap_content"
      android:layout_below="@id/times"
      android:layout_centerInParent="true"
      android:text="@string/done" />

<!-- here close of your created RelativeLayout -->
</RelativeLayout>


</RelativeLayout>

这是什么,listview还是什么?这是在相对布局中,有3个文本视图和6个按钮将所有这些视图放在一个真实的布局中,并使其高度和宽度与android:layout\u width=fill\u parent android:layout\u height=fill一样_parent@minafawzy由于fill\u parent已被弃用,您最好使用match\u parent