android - 线性布局内的两个框架布局

标签 android android-linearlayout android-framelayout

这是我现在的代码:

<?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:orientation="vertical" >

    <FrameLayout
        android:id="@+id/tablet_locations_fragment_fragment_container"
        android:layout_width="match_parent"
        android:layout_height="match_parent" />

    <FrameLayout
        android:id="@+id/tablet_locations_fragment_locations_fragment_list_container"
        android:layout_width="match_parent"
        android:layout_height="90dp" />

</LinearLayout>

我认为很明显,我希望底部框架布局为 90dp 高,顶部框架布局占据其余空间,但目前,上部框架布局占用了所有屏幕高度。我怎样才能解决这个问题?我尝试将 layout_height="wrap_content"用于上部框架布局,但它没有任何改变。

最佳答案

layout_weight 是你的 friend

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

    <FrameLayout
        android:id="@+id/tablet_locations_fragment_fragment_container"
        android:layout_width="match_parent"
        android:layout_weight="1"
        android:layout_height="0dp" />

    <FrameLayout
        android:id="@+id/tablet_locations_fragment_locations_fragment_list_container"
        android:layout_width="match_parent"
        android:layout_height="90dp" />

</LinearLayout>

关于android - 线性布局内的两个框架布局,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26807678/

相关文章:

java - 带有空引用的 Guava/Otto EventBus

java - 是否可以将按钮添加到以编程方式设置的框架布局?

javascript - 不使用 jQuery 在 Android WebView 中过滤 DOM 元素

java - @Override 不强制在重写方法中使用枚举注释

java - Android自定义对话框seekbar

java - ImageView 尺寸看起来比实际尺寸小

android - LinearLayout OnClickListener 没有响应

安卓预览布局

android - 如何在 FrameLayout 中排列元素?

android - 滑动以从 FrameLayout 中关闭 TextView