今天要介绍的元件,当介面的内容开始变多时就派上用场了,毕竟手机萤幕或着各类3c显示的大小都相当有限,在有大量内容或者制作类似电子书的样式时,可以透过ScrollView来制造滑动萤幕的效果,弥补萤幕不足的问题,使用方式也很简单,把需要滑动的内容放置ScrollView的标签之中即可,简单的示范配置如下。
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:layout_editor_absoluteX="159dp"
tools:layout_editor_absoluteY="99dp"
android:scrollbarStyle="insideInset">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView
android:id="@+id/textView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="TextView介绍"
android:textSize="30sp"
android:textStyle="bold" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/textview"
android:textSize="20sp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<TextView
android:id="@+id/EditText"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="EditView"
android:textSize="30sp"
android:textStyle="bold" />
<TextView
android:id="@+id/textView3"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/edittext"
android:textSize="20sp" />
</LinearLayout>
</ScrollView>
</androidx.constraintlayout.widget.ConstraintLayout>
这里介绍一下ScrollView的属性
android:scrollbarStyle 此属性是设定滑动的样式,包括以下四种:
<<: [Day 13] 阿嬷都看得懂的基础 CSS 选择器
>>: [Tableau Public] day 28:制作台湾姓氏分布-数据仪表板
客制化PWM 这里所说的客制化PWM指的就是我们可以输出任何想要的方波波形,例如输出10个完整的波後...
前几天在谈到人脸识别有提到:大部分使用神经网路的模型都可以侦测与识别口罩下的人脸。 纳今天如果我们只...
今日题目:409. Longest Palindrome Given a string s whic...
今日目标 学习了解 Python Pandas 的观念与运用 What is Pandas? Pan...
运算子算是比较繁杂的部分,需要多些耐心来理解与记忆,没办法用一个简明的观念来一以贯之。 算术运算子...