Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/200.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
Java 在我的代码中,线性布局的父级是什么?_Java_Android_Button - Fatal编程技术网

Java 在我的代码中,线性布局的父级是什么?

Java 在我的代码中,线性布局的父级是什么?,java,android,button,Java,Android,Button,这是我目前的代码 <LinearLayout 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:orientation="horizont

这是我目前的代码

<LinearLayout 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:orientation="horizontal" >

   <EditText android:id="@+id/edit_message"
       android:layout_weight = "1"
       android:layout_width = "0dp"
       android:layout_height= "wrap_content"
       android:hint = "@string/edit_message" />
   <Button
       android:layout_width = "wrap_content"
       android:layout_height= "wrap_content"
       android:text = "@string/submit"
       android:onClick = "sendMessage"  />


</LinearLayout>

我研究了术语match_parent,发现它与“父布局的大小”(Src:)


对于一个按钮,如果我指定match_parent,我知道父级将是线性布局。我的问题是,如果我在线性布局上指定match_parent,它将匹配哪个父级?该父项的术语是什么?

该线性布局的父项可以是一个活动(因此该线性布局将与您的设备屏幕一样大),或者是一个片段,或者是一个列表/网格项e.t.c。基本上,任何包含您的布局的视图组都可以使用该父项。

该父项的术语是什么?:对此没有明确的答案。可以使用您显示为
ListView
列表项的布局。在这种情况下,该布局的每个实例都会膨胀到
ListView
的子视图中,并且列表适配器中的项目数量与列表中的项目数量相同。您还可以将该布局用作
片段的主视图,该片段也可能与保存在“容器”中的其他片段一起出现在屏幕上,例如
FrameLayouts
。如果膨胀为<代码>活动< /代码>的布局(内容视图),则将父级视为<代码>窗口< /代码>。