美文网首页
ScrollView中嵌套LinearList,使用layout

ScrollView中嵌套LinearList,使用layout

作者: 萤火虫叔叔 | 来源:发表于2018-02-02 16:29 被阅读125次

其实很简单,ScrollView添加属性android:fillViewport="true"即可。例子见下方:

<ScrollView
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:fillViewport="true">

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:background="#FFFFFF"
        android:orientation="vertical">

        <TextView
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:background="#FF0000"
            android:text="萤火虫叔叔">
        </TextView>

        <TextView
            android:layout_width="match_parent"
            android:layout_height="0dp"
            android:background="#00FF00"
            android:layout_weight="1"
            android:text="萤火虫叔叔的尾巴">
        </TextView>
    </LinearLayout>
</ScrollView>

第二个的TextView会充满容器的剩余部分。

相关文章

网友评论

      本文标题:ScrollView中嵌套LinearList,使用layout

      本文链接:https://www.haomeiwen.com/subject/hbsezxtx.html