ScrollView中嵌套LinearList,使用layout

2018-02-02  本文已影响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会充满容器的剩余部分。

上一篇 下一篇

猜你喜欢

热点阅读