ScrollView滚动视图功能和用法

作者: 你好_摆渡人 | 来源:发表于2019-10-19 16:10 被阅读0次

ScrollView为垂直滚动条HorizontalScrollView为水平滚动
该示例就一个布局:

<?xml version="1.0" encoding="utf-8"?>
<ScrollView
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".MainActivity">
<HorizontalScrollView
    android:layout_width="match_parent"
    android:layout_height="wrap_content">

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical">
        <TextView
            android:text="花里胡哨"
            android:textSize="40dp"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content" />
        <TextView
            android:text="花里胡哨"
            android:textSize="40dp"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content" />
        <TextView
            android:text="花里胡哨"
            android:textSize="40dp"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content" />
        <TextView
            android:text="花里胡哨"
            android:textSize="40dp"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content" />
        <TextView
            android:text="花里胡哨"
            android:textSize="40dp"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content" />

        <TextView
            android:text="花里胡哨"
            android:textSize="40dp"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content" />
        <TextView
            android:text="花里胡哨"
            android:textSize="40dp"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content" />
        <TextView
            android:text="花里胡哨"
            android:textSize="40dp"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content" />
        <TextView
            android:text="花里胡哨"
            android:textSize="40dp"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content" />
        <TextView
            android:text="花里胡哨"
            android:textSize="40dp"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content" />
        <TextView
            android:text="花里胡哨"
            android:textSize="40dp"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content" />
        <TextView
            android:text="花里胡哨"
            android:textSize="40dp"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content" />
        <TextView
            android:text="花里胡哨"
            android:textSize="40dp"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content" />

    </LinearLayout>
</HorizontalScrollView>


</ScrollView>

效果图:


2.gif 1.gif

相关文章

网友评论

    本文标题:ScrollView滚动视图功能和用法

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