android学习笔记11——ScrollView

ScrollView——滚动条

用于内容显示不全,可提供滚动条下来形式,显示其余内容。

ScrollView和HorizontalScrollView是为控件或者布局添加滚动条

特点如下:

  1.只能有一个子控件

  2.两个控件可以互相嵌套

  3.ScrollView派生子FrameLayout

  4.ScrollView——垂直滚动条;HorizontalScrollView——水平滚动条

  5.属性scrollbars 可以设置滚动条的方向:但ScrollView设置为horizontal/none效果相同,HorizontalScrollView设置为vertical和none的效果相同

实例如下:

<HorizontalScrollView xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".MainActivity" >

    <LinearLayout
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal" >

        <TextView
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:text="0001" />

        <TextView
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:text="0001" />

    //足够多控件
     .......


</HorizontalScrollView>

允许效果:略

需要看ScrollView效果需将布局文件内容跟标签更改为“ScrollView”,同时修改线性布局控件的布局方式为垂直,即可......

原文地址:https://www.cnblogs.com/YYkun/p/5761272.html