Skip to content

Commit

Permalink
添加Material Design新控件上手Demo
Browse files Browse the repository at this point in the history
  • Loading branch information
D-clock committed Jul 29, 2016
1 parent 6053497 commit 2f906e6
Show file tree
Hide file tree
Showing 14 changed files with 174 additions and 36 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

本代码库整理总结 Android 系统自身UI特性,主要包含**代码实践****特性总结**两方面的内容。有兴趣的朋友欢迎fork、star、watch。

## 最新更新 (最后编辑于 2016-07-27
## 最新更新 (最后编辑于 2016-07-29

- 新增 Material Design 系列控件的体验,其中包括 SnackBar、FloatingActionButton、AppBarLayout、CardView、CoordinatorLayout、CollapsingToolbarLayout 等
- 新增 Material Design 系列控件的体验,其中包括 RecyclerView、SnackBar、FloatingActionButton、AppBarLayout、CardView、CoordinatorLayout、CollapsingToolbarLayout、BottomSheets
- 写一点个人感想,Android L 之后,嵌套滚动机制的应用越发重要了都。。。。。。。。

## 实践总结
Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,6 @@ dependencies {
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.1.1'
compile 'com.android.support:support-v4:23.1.1'
compile 'com.android.support:design:23.1.1'
compile 'com.android.support:design:23.2.0'
compile 'com.android.support:cardview-v7:23.1.1'
}
5 changes: 3 additions & 2 deletions src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,13 @@
android:name=".activity.snackbar.SnackBarDemoActivity"
android:label="SnackBar" />
<activity
android:name=".activity.bartab.BarTabDemoActivity"
android:name=".activity.bt.BarTabDemoActivity"
android:label="AppBarLayout" />
<activity
android:name=".activity.collapsing.CollapsingDemoActivity"
android:label="D_clock爱吃葱花" />
<activity android:name=".activity.recycler.RecyclerDemoActivity"></activity>
<activity android:name=".activity.recycler.RecyclerDemoActivity" />
<activity android:name=".activity.bs.BottomSheetsDemoActivity"></activity>
</application>

</manifest>
8 changes: 7 additions & 1 deletion src/main/java/com/clock/systemui/activity/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
import android.view.View;

import com.clock.systemui.R;
import com.clock.systemui.activity.bartab.BarTabDemoActivity;
import com.clock.systemui.activity.bs.BottomSheetsDemoActivity;
import com.clock.systemui.activity.bt.BarTabDemoActivity;
import com.clock.systemui.activity.cardview.CardViewDemoActivity;
import com.clock.systemui.activity.collapsing.CollapsingDemoActivity;
import com.clock.systemui.activity.navigation.NavigationDemoActivity;
Expand All @@ -30,6 +31,7 @@ protected void onCreate(Bundle savedInstanceState) {
findViewById(R.id.btn_snack_bar).setOnClickListener(this);
findViewById(R.id.btn_bar_tab).setOnClickListener(this);
findViewById(R.id.btn_collapsing).setOnClickListener(this);
findViewById(R.id.btn_bottom_sheets).setOnClickListener(this);

}

Expand Down Expand Up @@ -68,6 +70,10 @@ public void onClick(View v) {
Intent intent = new Intent(this, CollapsingDemoActivity.class);
startActivity(intent);

} else if (viewId == R.id.btn_bottom_sheets) {
Intent intent = new Intent(this, BottomSheetsDemoActivity.class);
startActivity(intent);

}

}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
package com.clock.systemui.activity.bs;

import android.support.design.widget.BottomSheetDialog;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.View;

import com.clock.systemui.R;
import com.clock.systemui.adapter.RecyclerItemAdapter;

public class BottomSheetsDemoActivity extends AppCompatActivity implements View.OnClickListener {

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_bottom_sheets_demo);

findViewById(R.id.btn_show_dialog).setOnClickListener(this);

}

@Override
public void onClick(View v) {
int viewId = v.getId();
if (viewId == R.id.btn_show_dialog) {
BottomSheetDialog dialog = new BottomSheetDialog(this);
View contentView = View.inflate(this, R.layout.bottom_sheets_layout, null);
RecyclerView itemView = (RecyclerView) contentView.findViewById(R.id.recycler_view);
RecyclerView.LayoutManager layoutManager = new LinearLayoutManager(this, LinearLayoutManager.VERTICAL, false);
itemView.setLayoutManager(layoutManager);
RecyclerView.Adapter adapter = new RecyclerItemAdapter();
itemView.setAdapter(adapter);
dialog.setContentView(contentView);
dialog.show();
}
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.clock.systemui.activity.bartab;
package com.clock.systemui.activity.bt;

import android.os.Bundle;
import android.support.design.widget.TabLayout;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,13 @@ protected void onCreate(Bundle savedInstanceState) {
mAuthorInfoList.add(authorInfo1);

AuthorInfo authorInfo2 = new AuthorInfo();
authorInfo1.setMotto("I am Android Developer!HaHaHaHaHaHaHaHaHa");
authorInfo1.setNickName("D_clock爱吃大西瓜西瓜西瓜西瓜西瓜");
authorInfo2.setMotto("I am Android Developer!HaHaHaHaHaHaHaHaHa");
authorInfo2.setNickName("D_clock爱吃大西瓜西瓜西瓜西瓜西瓜");
mAuthorInfoList.add(authorInfo2);

AuthorInfo authorInfo3 = new AuthorInfo();
authorInfo1.setMotto("Hello World!Hello World!Hello World!Hello World!Hello World!");
authorInfo1.setNickName("D_clock爱吃葱花葱花葱花葱花葱花葱花");
authorInfo3.setMotto("Hello World!Hello World!Hello World!Hello World!Hello World!");
authorInfo3.setNickName("D_clock爱吃葱花葱花葱花葱花葱花葱花");
mAuthorInfoList.add(authorInfo3);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.clock.systemui.adapter;

import android.support.v7.widget.RecyclerView;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
Expand Down
38 changes: 38 additions & 0 deletions src/main/java/com/clock/systemui/adapter/RecyclerItemAdapter.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
package com.clock.systemui.adapter;

import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.clock.systemui.R;

/**
* Created by Clock on 2016/7/29.
*/
public class RecyclerItemAdapter extends RecyclerView.Adapter<RecyclerItemAdapter.ItemHolder> {

@Override
public ItemHolder onCreateViewHolder(ViewGroup parent, int viewType) {
LayoutInflater inflater = LayoutInflater.from(parent.getContext());
View itemView = inflater.inflate(R.layout.bottom_sheets_item, parent, false);
return new ItemHolder(itemView);
}

@Override
public void onBindViewHolder(ItemHolder holder, int position) {

}

@Override
public int getItemCount() {
return 10;
}

class ItemHolder extends RecyclerView.ViewHolder {

public ItemHolder(View itemView) {
super(itemView);
}
}
}
17 changes: 17 additions & 0 deletions src/main/res/layout/activity_bottom_sheets_demo.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin">

<Button
android:id="@+id/btn_show_dialog"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Show Bottom Sheets Dialog" />
</LinearLayout>
6 changes: 6 additions & 0 deletions src/main/res/layout/activity_main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -55,4 +55,10 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="CollapsingToolbarLayout" />

<Button
android:id="@+id/btn_bottom_sheets"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Bottom Sheets Demo" />
</LinearLayout>
48 changes: 23 additions & 25 deletions src/main/res/layout/author_small_card_layout.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,43 +14,41 @@
cardview:cardCornerRadius="4dp"
cardview:cardElevation="4dp">

<LinearLayout
android:layout_width="180dp"
android:layout_height="wrap_content"
android:orientation="vertical">
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content">

<LinearLayout
<ImageView
android:id="@+id/iv_portrait"
android:layout_width="70dp"
android:layout_height="70dp"
android:layout_margin="5dp"
android:src="@mipmap/lufy" />

<TextView
android:id="@+id/tv_nickname"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal">

<ImageView
android:id="@+id/iv_portrait"
android:layout_width="70dp"
android:layout_height="70dp"
android:layout_margin="5dp"
android:src="@mipmap/lufy" />

<TextView
android:id="@+id/tv_nickname"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:text="D_clock爱吃葱花"
android:textSize="20sp"
android:textStyle="bold" />
</LinearLayout>

android:layout_marginTop="10dp"
android:layout_toRightOf="@id/iv_portrait"
android:maxLines="3"
android:maxWidth="100dp"
android:text="D_clock爱吃葱花"
android:textSize="20sp"
android:textStyle="bold" />

<TextView
android:id="@+id/tv_motto"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/iv_portrait"
android:layout_marginBottom="5dp"
android:layout_marginLeft="5dp"
android:layout_marginTop="5dp"
android:maxLines="5"
android:maxWidth="180dp"
android:text="Diycode 大管家,闭关写代码" />
</LinearLayout>
</RelativeLayout>

</android.support.v7.widget.CardView>
</LinearLayout>
21 changes: 21 additions & 0 deletions src/main/res/layout/bottom_sheets_item.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?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="wrap_content"
android:orientation="vertical">

<android.support.v7.widget.CardView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="5dp">

<TextView
android:id="@+id/tv_item"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:padding="10dp"
android:text="D_clock爱吃葱花" />
</android.support.v7.widget.CardView>

</LinearLayout>
11 changes: 11 additions & 0 deletions src/main/res/layout/bottom_sheets_layout.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?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"
android:orientation="vertical">

<android.support.v7.widget.RecyclerView
android:id="@+id/recycler_view"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</LinearLayout>

0 comments on commit 2f906e6

Please sign in to comment.