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

更多相关文章

  1. 【Android布局】在程序中设置android:gravity 和 android:layout
  2. 元素可指定如下常用属性
  3. 【Android布局】在程序中设置android:gravity 和 android:layout
  4. 【Android布局】在程序中设置android:gravity 和 android:layout
  5. [android]EditText的一些设置
  6. Android中TextView跑马灯没效果解决
  7. EditText光标居上
  8. Android:实现无标题的两种方法
  9. 去掉RecycleView或者ListView上下滑动阴影的方法

随机推荐

  1. Android透明字体画法
  2. android 探索首选项框架 ListPreference
  3. Android实现打电话功能
  4. android实现涂鸦,保存涂鸦后的图片,清屏
  5. Install Android(安卓)Composite ADB Int
  6. Android四大组件Service之bindService启
  7. android native call only, no third par
  8. Android实践之TabActivity
  9. How to parse / read JSON data into a A
  10. android 手机判断是否在充电 如断电自动