第六周星期四每日总结

    今日在地铁查询app时学会了如何在页面中添加垂直和水平滚动条,并且学会如何控制组件布局距离底部的距离。

代码举例:

 1 <?xml version="1.0" encoding="utf-8"?>
 2 <ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
<!--ScrollView可控制页面添加一个垂直的滚动条,支持上下滑动查看数据    -->
 3     xmlns:app="http://schemas.android.com/apk/res-auto"
 4     xmlns:tools="http://schemas.android.com/tools"
 5     android:layout_width="match_parent"
 6     android:layout_height="match_parent"
 7     android:background="@drawable/dp2"
 8     >
 9     `
10     <LinearLayout
11         android:layout_width="match_parent"
12         android:layout_height="match_parent"
13         android:orientation="vertical"
14         android:layout_marginTop="70dp">
15         <TextView
16             android:layout_width="wrap_content"
17             android:layout_height="wrap_content"
18             android:text="线路查询"
19             android:textSize="40dp"
20             android:textColor="@color/black"
21             android:layout_gravity="center"
22             />
23         <EditText
24             android:id="@+id/search"
25             android:layout_marginTop="40dp"
26             android:layout_width="match_parent"
27             android:layout_height="match_parent"
28             android:hint="线路查询"
29             />
30         <Button
31             android:id="@+id/btn_choice1"
32             android:layout_width="300dp"
33             android:layout_gravity="center"
34             android:layout_height="50dp"
35             android:layout_marginTop="20dp"
36             android:padding="10dp"
37             android:background="@drawable/but_on"
38             android:text="查            询"/>
39         <HorizontalScrollView
<!--
HorizontalScrollView可添加水平的滚动条
-->
40 41 android:layout_width="wrap_content" 42 43  android:layout_height="match_parent"> 44 <LinearLayout 45 android:layout_width="match_parent" 46  android:layout_height="wrap_content" 47  android:orientation="horizontal" 48  android:layout_marginBottom="100dp"
<!--
android:layout_marginBottom="100dp"可控制组件距离底部的距离,适当调整可让数据显示完全
-->

49 > 50 <TextView 51 android:layout_width="wrap_content" 52 android:layout_height="wrap_content" 53 android:layout_weight="1" 54 android:id="@+id/tv_show" 55 android:textSize="20sp" 56 android:gravity="center_horizontal"/> 57 <TextView 58 android:layout_width="wrap_content" 59 android:layout_height="wrap_content" 60 android:layout_weight="1" 61 android:id="@+id/tv_showx" 62 android:textSize="20sp" 63 android:gravity="center_horizontal" 64 /> 65 <TextView 66 android:layout_width="wrap_content" 67 android:layout_height="wrap_content" 68 android:layout_weight="1" 69 android:id="@+id/tv_showy" 70 android:textSize="20sp" 71 android:gravity="center_horizontal" 72 /> 73 </LinearLayout> 74 </HorizontalScrollView> 75 </LinearLayout> 76 77 </ScrollView>

 

posted on 2023-03-23 22:02  樱华旧梦  阅读(23)  评论(0)    收藏  举报