【问题标题】:Relative layout height set to match_parent work as wrap_content设置为 match_parent 的相对布局高度用作 wrap_content
【发布时间】:2016-03-20 21:50:35
【问题描述】:

我有一个relative layout,其中有ScrollView,它包含另一个RelativeLayout。子相对布局 layout_height 设置为 match_parent 但它的反应是其设置为 wrap_content

这里是xml代码

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:paddingBottom="@dimen/activity_vertical_margin"
    android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin"
    app:layout_behavior="@string/appbar_scrolling_view_behavior"
    tools:context="com.digitnomics.isite.Signage"
    tools:showIn="@layout/activity_signage">

    <ScrollView
        android:id="@+id/scrollView2"
        android:layout_width="match_parent"
        android:layout_height="match_parent">

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

这里是布局预览

ScrollView 设置为 match_parent

Child RelativeLayout 设置为 match_parent

如何强制子相对布局layout_height 填充整个高度?

【问题讨论】:

    标签: android android-layout android-relativelayout


    【解决方案1】:

    在你的 ScrollView 集合中

    android:fillViewport="true"
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2022-08-14
      • 2017-12-17
      • 1970-01-01
      • 2017-04-03
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多