在上一个项目的开发中,遇到了一个比较复杂的界面。之后研究之后采用5.0之后的design包下的控件实现。
首先上效果图。
在这个简单的demo中,我把这个View分为两个部分。
1、常驻部分。定义在Activity中
2、内容显示部分。定义在Activity的Fragment中。
常驻部分的布局非常简单,就不再赘述。重要的是内容显示部分的实现。
在内容显示部分就要用到design包下的内容了,以下是内容部分的布局
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/main_content"
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.design.widget.AppBarLayout
android:id="@+id/appbar"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
app:layout_scrollFlags="scroll">
<TextView
android:layout_width="match_parent"
android:layout_height="100dp"
android:background="@android:color/holo_orange_dark"