Skip to content

Commit 59ac950

Browse files
committed
CoordinatorLayout
1 parent 21c8e7c commit 59ac950

File tree

5 files changed

+83
-0
lines changed

5 files changed

+83
-0
lines changed

app/src/main/AndroidManifest.xml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@
2525
<activity
2626
android:name=".TabLayoutActivity"
2727
android:theme="@style/AppThemeNoActionBar"></activity>
28+
<activity
29+
android:name=".CoordinatorLayoutActivity"
30+
android:theme="@style/AppThemeNoActionBar"></activity>
2831
</application>
2932

3033
</manifest>
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
package com.wega.materialdesignwidget;
2+
3+
import android.os.Bundle;
4+
import android.support.v7.app.AppCompatActivity;
5+
import android.support.v7.widget.Toolbar;
6+
7+
public class CoordinatorLayoutActivity extends AppCompatActivity {
8+
9+
@Override
10+
protected void onCreate(Bundle savedInstanceState) {
11+
super.onCreate(savedInstanceState);
12+
setContentView(R.layout.activity_coordinator_layout);
13+
Toolbar mToolbar = findViewById(R.id.toolbar);
14+
mToolbar.setTitle("CoordinatorLayout");
15+
setSupportActionBar(mToolbar);
16+
}
17+
}

app/src/main/java/com/wega/materialdesignwidget/MainActivity.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ protected void onCreate(Bundle savedInstanceState) {
1313
setContentView(R.layout.activity_main);
1414
findViewById(R.id.btn_toolbar).setOnClickListener(this);
1515
findViewById(R.id.btn_NestedScrollView).setOnClickListener(this);
16+
findViewById(R.id.btn_CoordinatorLayout).setOnClickListener(this);
1617
findViewById(R.id.btn_TabLayout).setOnClickListener(this);
1718

1819
}
@@ -31,6 +32,10 @@ public void onClick(View v) {
3132
case R.id.btn_NestedScrollView:
3233
intent.setClass(this,NestedScrollViewActivity.class);
3334

35+
break;
36+
case R.id.btn_CoordinatorLayout:
37+
intent.setClass(this,CoordinatorLayoutActivity.class);
38+
3439
break;
3540
case R.id.btn_TabLayout:
3641
intent.setClass(this,TabLayoutActivity.class);
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<android.support.design.widget.CoordinatorLayout
3+
xmlns:android="http://schemas.android.com/apk/res/android"
4+
xmlns:tools="http://schemas.android.com/tools"
5+
android:layout_width="match_parent"
6+
android:layout_height="match_parent" xmlns:app="http://schemas.android.com/apk/res-auto"
7+
tools:context="com.wega.materialdesignwidget.CoordinatorLayoutActivity">
8+
9+
10+
11+
<android.support.v7.widget.Toolbar
12+
android:id="@+id/toolbar"
13+
android:background="?attr/colorPrimary"
14+
android:layout_width="match_parent"
15+
app:theme="@style/ThemeOverlay.AppCompat.Dark"
16+
android:layout_height="wrap_content">
17+
18+
</android.support.v7.widget.Toolbar>
19+
20+
21+
<android.support.v4.widget.NestedScrollView
22+
android:layout_width="match_parent"
23+
android:layout_height="match_parent"
24+
android:layout_marginTop="?actionBarSize"
25+
>
26+
27+
<LinearLayout
28+
android:layout_width="match_parent"
29+
android:orientation="vertical"
30+
android:layout_height="match_parent">
31+
32+
<TextView
33+
android:layout_width="match_parent"
34+
android:text="这里简单展示跟FrameLayout一样的用法,增强behavior用法请看下面AppBarLayoutActivity等"
35+
android:background="#cdcdcd"
36+
android:layout_height="400dp"/>
37+
<TextView
38+
android:layout_width="match_parent"
39+
android:background="#ababab"
40+
android:layout_height="400dp"/>
41+
<TextView
42+
android:layout_width="match_parent"
43+
android:background="#fafafa"
44+
android:layout_height="400dp"/>
45+
</LinearLayout>
46+
47+
48+
</android.support.v4.widget.NestedScrollView>
49+
50+
</android.support.design.widget.CoordinatorLayout>

app/src/main/res/layout/activity_main.xml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,14 @@
3838
android:textAllCaps="false"
3939
android:layout_margin="8dp"
4040
/>
41+
<Button
42+
android:id="@+id/btn_CoordinatorLayout"
43+
android:layout_width="match_parent"
44+
android:layout_height="wrap_content"
45+
android:text="CoordinatorLayout"
46+
android:textAllCaps="false"
47+
android:layout_margin="8dp"
48+
/>
4149
<Button
4250
android:id="@+id/btn_TabLayout"
4351
android:layout_width="match_parent"

0 commit comments

Comments
 (0)