滚动视图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>
相关推荐
TeDi TIVE7 分钟前
Spring Cloud Gateway
java
:mnong38 分钟前
Superpowers 项目设计分析
java·c语言·c++·python·c#·php·skills
扶苏-su1 小时前
Java--获取 Class 类对象
java·开发语言
东离与糖宝1 小时前
LangChain4j vs Spring AI:最新对比,Java企业级Agent开发
java·人工智能
96771 小时前
C++多线程2 如何优雅地锁门 (lock_guard) 多线程里的锁的种类
java·开发语言·c++
老衲提灯找美女2 小时前
数据库事务
java·大数据·数据库
Mem0rin2 小时前
[Java/数据结构]线性表之链表
java·数据结构·链表
香香甜甜的辣椒炒肉2 小时前
Spring(1)基本概念+开发的基本步骤
java·后端·spring
成都渲染101云渲染66663 小时前
跳出“硬件堆砌”陷阱|渲染101如何用技术重构云渲染的专业价值?
java·前端·javascript
golang学习记3 小时前
IDEA 2026.1全新调试新特性:Spring Boot调试不再靠猜!
java·spring boot·intellij-idea