Android开发
Android高级控件的使用:
ScrollView的使用方法:
1.改变这个布局文件的根布局:把根布局改成:ScrollView
注意:ScrollView的子元素只能有一个,所以得增加一个LinearLayout布局,把其他按键放在这个LinearLayout中,那么ScrollViewd的子元素就只有一个LinearLayout了,而LinearLayout的子元素不限制。
代码如下:
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:padding="10dp">
    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical"
        >
        <Button
            android:id="@+id/IVButton_Id"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:text="跳转到ImageView"
            android:textSize="20dp"
            android:textAllCaps="false"/>
        <Button
            android:id="@+id/LVButton_Id"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:text="跳转到ListView"
            android:textSize="20dp"
            android:textAllCaps="false"/>
        <Button
            android:id="@+id/GVButton_Id"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:text="跳转到GridView"
            android:textSize="20dp"
            android:textAllCaps="false"/>
 
        <Button
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:text="按钮1"
            android:textSize="20dp"
            android:textAllCaps="false"
            android:layout_marginTop="100dp"/>
        <Button
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:text="按钮2"
            android:textSize="20dp"
            android:textAllCaps="false"
            android:layout_marginTop="100dp"/>
        <Button
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:text="按钮3"
            android:textSize="20dp"
            android:textAllCaps="false"
            android:layout_marginTop="300dp"/>
    </LinearLayout>
 
</ScrollView>
运行程序,现在就可以向下滚动,看到按钮3了:
————————————————
版权声明:本文为CSDN博主「冷暖自知_源」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/qq_36243942/article/details/82185051

 
                
            
         浙公网安备 33010602011771号
浙公网安备 33010602011771号