【开源】MaterialDesignLibrary

MaterialDesignLibrary

  •  https://github.com/navasmdc/MaterialDesignLibrary

    介绍:

    实现了android L中的各种控件效果,包括浮动操作按钮Flat Button、checkbox、进度条、开关、slider(滑杆)、对话框、颜色选择等,这完全是作者自己实现的控件,因此兼容2.2。

    运行效果:

使用说明:

矩形按钮

1
2
3
4
5
6
<com.gc.materialdesign.views.ButtonRectangle
                android:id="@+id/button"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:background="#1E88E5"
                android:text="Button" />

浮动操作按钮

一般我们将这种按钮放在界面的右下角。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:materialdesign="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    >
    <!-- ... XML CODE -->
    <com.gc.materialdesign.views.ButtonFloat
                android:id="@+id/buttonFloat"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_alignParentRight="true"
                android:layout_alignParentBottom="true"
                android:layout_marginRight="24dp"
                android:background="#1E88E5"
                materialdesign:animate="true"
                materialdesign:icon="@drawable/ic_action_new" />
</RelativeLayout>

checkbox

1
2
3
4
5
6
<com.gc.materialdesign.views.CheckBox
                android:id="@+id/checkBox"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:background="#1E88E5"
                materialdesign:check="true" />

switch

1
2
3
4
5
6
<com.gc.materialdesign.views.Switch
                android:id="@+id/switchView"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:background="#1E88E5"
                materialdesign:check="true" />

圆形进度条

1
2
3
4
5
<com.gc.materialdesign.views.ProgressBarCircularIndetermininate
                android:id="@+id/progressBarCircularIndetermininate"
                android:layout_width="32dp"
                android:layout_height="32dp"
                android:background="#1E88E5" />

条形运动型进度条

1
2
3
4
5
<com.gc.materialdesign.views.ProgressBarIndeterminate
                android:id="@+id/progressBarIndeterminate"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:background="#1E88E5" />

滑杆slider

1
2
3
4
5
6
7
8
<com.gc.materialdesign.views.Slider
                android:id="@+id/slider"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:background="#1E88E5"
                materialdesign:max="50"
                materialdesign:min="0"
                 />

带数字指示的滑杆

1
2
3
4
5
6
7
8
<com.gc.materialdesign.views.Slider
                android:id="@+id/slider"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:background="#1E88E5"
                materialdesign:max="50"
                materialdesign:min="0"
                materialdesign:showNumberIndicator="true"/>

对话框

1
2
Dialog dialog = new Dialog(Context context,String title, String message);
dialog.show();

设置对话框的确认和取消按钮

1
2
3
4
5
6
7
8
// Set accept click listenner
dialog.setOnAcceptButtonClickListener(View.OnClickListener onAcceptButtonClickListener);
// Set cancel click listenner
dialog.setOnCancelButtonClickListener(View.OnClickListener onCancelButtonClickListener);
// Acces to accept button
ButtonFlat acceptButton = dialog.getButtonAccept();
// Acces to cancel button
ButtonFlat cancelButton = dialog.getButtonCancel();

颜色选择

1
2
ColorSelector colorSelector = new ColorSelector(Context context,int intialColor, OnColorSelectedListener onColorSelectedListener);
colorSelector.show();

posted on 2015-03-31 12:09  wasdchenhao  阅读(152)  评论(0)    收藏  举报

导航