滚动视图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>
相关推荐
lunzi_fly1 分钟前
【源码解读之 Mybatis】【基础篇】-- 第1篇:MyBatis 整体架构设计
java·mybatis
JIngJaneIL17 分钟前
汽车租赁|基于Java+vue的汽车租赁系统(源码+数据库+文档)
java·vue.js·spring boot·汽车·论文·毕设·汽车租赁系统
渣哥32 分钟前
有一天,我和 CopyOnWriteArrayList 杯“线程安全”的咖啡
java
叽哥38 分钟前
Kotlin学习第 3 课:Kotlin 流程控制:掌握逻辑分支与循环的艺术
android·java·kotlin
杨杨杨大侠39 分钟前
第5章:实现Spring Boot集成
java·github·eventbus
CYRUS_STUDIO41 分钟前
别让 so 裸奔!移植 OLLVM 到 NDK 并集成到 Android Studio
android·android studio·llvm
华仔啊41 分钟前
工作5年没碰过分布式锁,是我太菜还是公司太稳?网友:太真实了!
java·后端
尚久龙1 小时前
安卓学习 之 图片控件和图片按钮
android·java·学习·手机·android studio·安卓
摸鱼仙人~1 小时前
深入理解 MyBatis-Plus 的 `BaseMapper`
java·开发语言·mybatis
杨杨杨大侠1 小时前
第6章:高级特性与性能优化
java·github·eventbus