android - 如何在 ScrollView 中将 LinearLayout 高度设置为匹配父级

标签 android android-layout scrollview

下面是我的 .XML 代码。我能有一个解决这个问题的方法吗?

<ScrollView 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:id="@+id/ticket_container"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:isScrollContainer="true">

    <LinearLayout 
    android:layout_width="match_parent"
    android:layout_height="wrap_content"/>

</ScrollView>

最佳答案

试试这个,我想它可以帮助你。

<ScrollView 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:id="@+id/ticket_container"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:fillViewport="true"
        android:isScrollContainer="true">

        <LinearLayout 
        android:layout_width="match_parent"
        android:layout_height="wrap_content"/>

    </ScrollView>

关于android - 如何在 ScrollView 中将 LinearLayout 高度设置为匹配父级,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50578024/

相关文章:

android - 带有粘性 TabStrip header 的滚动 viewpager

java - Android - OnClick 在子类中而不是 super 中使用

android - 为什么在将可绘制文件重命名为 .9.png 后,某些文件处理失败?

android - 以编程方式将 View 从一点动画到另一点 Android

android - Viewpager 的静态页眉和页脚

android - 仅在 Lollipop 设备上崩溃,: VrVideoView$Options 的解析失败

android - 如何获取 Android 本地服务实例

android - 媒体编解码器 : how to measure performance?

cocoa - 使用 ScrollView 打开 url(博客)

android - RelativeLayout 中的一组备用 TextView 和 ExpandableListView 在占用额外的屏幕空间时不可滚动