Android记事本NotePad应用功能拓展(四)
16lz
2021-01-23
Android记事本NotePad应用功能拓展(四)
一、实现功能
1.绘制设置界面
二、项目代码分析
1.点击待办事件添加计划Plan
设置界面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" xmlns:app="http://schemas.android.com/apk/res-auto" android:orientation="vertical" android:background="?attr/lvBackground"> <android.support.v7.widget.Toolbar android:id="@+id/my_toolbar" android:layout_width="match_parent" android:layout_height="?attr/actionBarSize" android:background="?attr/colorPrimary" android:elevation="4dp" app:titleTextColor="?attr/titleColor" app:title="设置" android:theme="@style/ThemeOverlay.AppCompat.ActionBar" app:popupTheme="@style/ThemeOverlay.AppCompat.Light"/> <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_margin="20dp" android:orientation="horizontal"> <LinearLayout android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_weight="1" android:orientation="vertical"> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="夜间模式" android:textColor="?attr/tvMainColor" android:textSize="20dp" /> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/pref_night_summary" android:textColor="?attr/tvSubColor" android:textSize="16dp" /> </LinearLayout> <Switch android:id="@+id/nightMode" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginLeft="10dp" android:layout_marginTop="10dp" android:clickable="true" android:gravity="center" android:switchMinWidth="50dp" /> </LinearLayout> <View android:layout_width="match_parent" android:layout_height="1dp" android:layout_marginLeft="10dp" android:layout_marginRight="10dp" android:foreground="@color/greyC" /> <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_margin="20dp" android:orientation="horizontal"> <LinearLayout android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_weight="1" android:orientation="vertical"> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/pref_reversesort" android:textColor="?attr/tvMainColor" android:textSize="20dp" /> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/pref_reversesort_summary" android:textColor="?attr/tvSubColor" android:textSize="16dp" /> </LinearLayout> <Switch android:id="@+id/reverseSort" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginLeft="10dp" android:layout_marginTop="10dp" android:checked="false" android:gravity="center" android:switchMinWidth="50dp" android:textOff="关闭" android:textOn="打开" /> </LinearLayout> <View android:layout_width="match_parent" android:layout_height="1dp" android:layout_marginLeft="10dp" android:layout_marginRight="10dp" android:foreground="@color/greyC" /> <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_margin="20dp" android:orientation="horizontal"> <LinearLayout android:id="@+id/fabColor" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_weight="1" android:orientation="horizontal"> <LinearLayout android:layout_width="wrap_content" android:layout_height="wrap_content" android:orientation="vertical" android:layout_weight="1" > <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/pref_fabcolor" android:textColor="?attr/tvMainColor" android:textSize="20dp" /> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/pref_fabcolor_summary" android:textColor="?attr/tvSubColor" android:textSize="16dp" /> </LinearLayout> <ImageView android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center_vertical" android:layout_marginEnd="15dp" android:layout_marginStart="15dp" android:src="?attr/addTag" /> </LinearLayout> </LinearLayout> <View android:layout_width="match_parent" android:layout_height="1dp" android:layout_marginLeft="10dp" android:layout_marginRight="10dp" android:foreground="@color/greyC" /> <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_margin="20dp" android:orientation="horizontal"> <LinearLayout android:id="@+id/fabPlanColor" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_weight="1" android:orientation="vertical"> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/pref_fabplancolor" android:textColor="?attr/tvMainColor" android:textSize="20dp" /> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/pref_fabplancolor_summary" android:textColor="?attr/tvSubColor" android:textSize="16dp" /> </LinearLayout> <ImageView android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="?attr/addPlanTag" android:layout_marginStart="15dp" android:layout_marginEnd="15dp" android:layout_gravity="center_vertical"/> </LinearLayout> <View android:layout_width="match_parent" android:layout_height="1dp" android:layout_marginLeft="10dp" android:layout_marginRight="10dp" android:foreground="@color/greyC" /> <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_margin="20dp" android:orientation="horizontal"> <LinearLayout android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_weight="1" android:orientation="vertical"> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/pref_notetitle" android:textColor="?attr/tvMainColor" android:textSize="20dp" /> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/pref_notetitle_summary" android:textColor="?attr/tvSubColor" android:textSize="16dp" /> </LinearLayout> <Switch android:id="@+id/noteTitle" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginLeft="10dp" android:layout_marginTop="10dp" android:clickable="true" android:gravity="center" android:switchMinWidth="50dp" /> </LinearLayout> <View android:layout_width="match_parent" android:layout_height="1dp" android:layout_marginLeft="10dp" android:layout_marginRight="10dp" android:foreground="@color/greyC" /></LinearLayout>
三、参考资料
相关参考:Android记事本NotePad应用功能拓展(一)
作者GitHub下载链接:https://github.com/KangKangBigWorld/Android/tree/master/Mid_Test
更多相关文章
- Android控件笔记——在界面中显示及输入文本信息
- Android异步处理系列文章四篇之一使用Thread+Handler实现非UI线
- Android 界面布局之RelativeLayout
- 使用AsyncTask异步更新UI界面
- android开发,修改默认界面的背景色
- Android常用UI界面设计及国际化
- 让star也具有CheckBox 功能
- 关于Android软键盘弹出,会把原来的界面挤上去的问题
- android 界面中加入密码框