android - 如何在android中的相对布局内安排两个线性布局?

标签 android android-layout layout android-linearlayout android-relativelayout

所附图片包含3 布局

  1. 相对布局
  2. 线性布局
  3. 线性布局

两个线性布局大小相同并且重叠

我只想知道如何在相对布局内安排这两个线性布局,以便线性布局 1线性布局 2 将具有 90% parent 高度。此外,线性布局 1 必须对齐到相对布局的顶部,而线性布局 2 必须对齐到相对布局的底部布局。

任何简单的工作解决方案将不胜感激。(我是 android studio 的新手)

enter image description here

最佳答案

来自 Android documentation :

<android.support.percent.PercentRelativeLayout
         xmlns:android="http://schemas.android.com/apk/res/android"
         xmlns:app="http://schemas.android.com/apk/res-auto"
         android:layout_width="match_parent"
         android:layout_height="match_parent">
     <LinearLayout
         android:layout_width="match_parent"
         app:layout_heightPercent="90%"
         android:layout_alignParentTop="true"/>
     <LinearLayout
         android:layout_width="match_parent"
         app:layout_heightPercent="90%"
         android:layout_alignParentBottom="true"/>
 </android.support.percent.PercentRelativeLayout>

LinearLayouts 重叠的顺序对应于它们的定义顺序。

关于android - 如何在android中的相对布局内安排两个线性布局?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38421843/

相关文章:

css - 在 2 列布局中定位 div 图片

android - 自定义加载器,如 Android 中的 Instagram

android - Glass GDK 高频 LiveCard 你好,世界例子?

android setvisibility gone 不释放空间

android - 对齐单选组内的单选按钮

android - ImageView 在图像的顶部和底部显示空白

java - 从Android上传图片到PHP服务器

android - 谷歌地图 android 2.2 NoClassDefFoundError

java - LinearLayout 不测量内部的 TextView

css - 如何设置元素的高度以填充其父元素高度的剩余部分?