滚动视图ScrollView

activity_scroll_view.xml

复制代码
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical">

    <HorizontalScrollView
        android:layout_width="wrap_content"
        android:layout_height="200dp">

        <!-- 水平方向的线性布局,两个子视图的颜色分别为青色和黄色 -->
        <LinearLayout
            android:layout_width="wrap_content"
            android:layout_height="match_parent"
            android:orientation="horizontal">

            <View
                android:layout_width="300dp"
                android:layout_height="match_parent"
                android:background="#aaffff"
                android:contentDescription="青色视图" />
            <View
                android:layout_width="300dp"
                android:layout_height="match_parent"
                android:background="#ffff00"
                android:contentDescription="黄色视图" />

        </LinearLayout>

    </HorizontalScrollView>
    
    <ScrollView
        android:layout_width="match_parent"
        android:layout_height="wrap_content">

        <!-- 垂直方向的线性布局,两个子视图的颜色分别为绿色和橙色 -->
        <LinearLayout
            android:layout_width="wrap_content"
            android:layout_height="match_parent"
            android:orientation="vertical">

            <View
                android:layout_width="match_parent"
                android:layout_height="400dp"
                android:background="#00ff00"
                android:contentDescription="青色视图" />
            <View
                android:layout_width="match_parent"
                android:layout_height="400dp"
                android:background="#ffffaa"
                android:contentDescription="黄色视图" />

        </LinearLayout>

    </ScrollView>

</LinearLayout>

AndroidManifest.xml

复制代码
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android">

    <application
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:roundIcon="@mipmap/ic_launcher_round"
        android:supportsRtl="true"
        android:theme="@style/Theme.MyApplication">
        <activity
            android:name=".ScrollViewActivity"
            android:exported="true" />

        <intent-filter>
            <action android:name="android/intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </application>

</manifest>
相关推荐
Hello World......16 分钟前
互联网大厂Java面试:从Spring到微服务的全面探讨
java·spring boot·spring cloud·微服务·面试·技术栈·互联网大厂
拾贰_C1 小时前
【SpringBoot】MyBatisPlus(MP | 分页查询操作
java·spring boot·后端·spring·maven·apache·intellij-idea
猛踹瘸子那条好腿の1 小时前
Spring-boot初次使用
java·springboot
我不是程序猿儿3 小时前
【C#】 lock 关键字
java·开发语言·c#
tmacfrank4 小时前
网络编程中的直接内存与零拷贝
java·linux·网络
weixin_472339465 小时前
Maven 下载安装与配置教程
java·maven
Magnum Lehar6 小时前
3d游戏引擎EngineTest的系统实现3
java·开发语言·游戏引擎
就叫飞六吧6 小时前
Spring Security 集成指南:避免 CORS 跨域问题
java·后端·spring
Mcworld8576 小时前
java集合
java·开发语言·windows
天黑请闭眼6 小时前
IDEA:程序编译报错:java: Compilation failed: internal java compiler error
java·intellij-idea