1.设计知识:
framelayout、floatingactionbutton、menu、listview、adapter、sqlite
2.开发工具:
Android Studio 3.1.1
工程目录:
3.界面设计:
a.主界面:
<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<ListView
android:id="@+id/layout_listview"
android:layout_width="match_parent"
android:layout_height="match_parent">
</ListView>
<android.support.design.widget.FloatingActionButton
android:id="@+id/add_note"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom|end"
android:layout_margin="15dp"
android:src="@mipmap/add_picture"
/>
</FrameLayout>
</android.support.design.widget.CoordinatorLayout>
页面如下:
注意:
当我们使用floatingactionbutton时,一定是要在framelayout布局之内放置listview和floatingactionbutton,如果不是这样,会因为布局的重合而导致floatingactionbutton被覆盖掉,而使用framelayout页面重合时只是重合布局之内的控件,而不会覆盖前面的布局的东西(具体原因请查看博客:https://blog.youkuaiyun.com/major_out/article/details/50656383)
b.新建页面/显示页面:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true">
<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_margin="10dp"
>
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="@string/new_title"
android:textSize="24dp"
android:textColor="@color/colorPrimaryDark"
/>
<EditText
android:id="@+id/title"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="4"
android:hint="@string/new_settitle"
android:ems="10"
android:textSize="24dp"
/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="@string/new_content"
android:textColor="@color/colorPrimaryDark"
android:textSize="24dp" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="10dp">
<EditText
android:id="@+id/content"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="top"
android:hint="@string/new_inputcontent"
android:textSize="24dp"
android:background="@null"/>
</LinearLayout>