Android代码整理,material design 的android开源代码整理

28b3e536bff6a2a0dce7bc60c0af37ed.png

Material Design Android Library

2b3970c4cfb828268ce561be0c6336ab.png

68747470733a2f2f696d672e736869656c64732e696f2f62616467652f416e64726f6964253230417273656e616c2d4d6174657269616c25323044657369676e253230416e64726f69642532304c6962726172792d627269676874677265656e2e7376673f7374796c653d666c6174

How to use

If you want use this library, you only have to download MaterialDesign project, import it into your workspace and add the project as a library in your android project settings.

If you prefer it, you can use the gradle dependency, you have to add these lines in your build.gradle file:

repositories {

jcenter()

}

dependencies {

compile ‘com.github.navasmdc:MaterialDesign:[email protected]

}

Some components have custom attributes, if you want use them, you must add this line in your xml file in the first component:

xmlns:materialdesign="http://schemas.android.com/apk/res-auto"

android:layout_width="match_parent"

android:layout_height="match_parent"

>

If you are going to use a ScrollView, it is recommended that you use the CustomScrollView provided in this library to avoid problems with the custom components. To use this component:

xmlns:android="http://schemas.android.com/apk/res/android"

xmlns:materialdesign="http://schemas.android.com/apk/res-auto"

android:id="@+id/scroll"

android:layout_width="match_parent"

android:layout_height="match_parent">

##Components

####Buttons

######Flat Button

789b1da319e4c83209a9e01d6383e7ab.png

android:id="@+id/buttonflat"

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:background="#1E88E5"

android:text="Button" />

######Rectangle Button

c84b8b632a55614b99d7beabd6441f2c.png

android:id="@+id/button"

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:background="#1E88E5"

android:text="Button" />

######Float Button

fdd445a263558f96739052af8a5bf796.png

It is recommended to put this component in the right-bottom of the screen. To use this component write this code in your xml file. If you don`t want to start this component with animation set the animate attribute to false. Put your icon in the icon attribute to set the drawable icon for this component.

xmlns:materialdesign="http://schemas.android.com/apk/res-auto"

android:layout_width="match_parent"

android:layout_height="match_parent"

>

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:iconDrawable="@drawable/ic_action_new" />

######Float small button

73eee85c73c2349cc67b20cca3ee7adb.png

android:id="@+id/buttonFloatSmall"

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:background="#1E88E5"

materialdesign:iconDrawable="@drawable/ic_action_new" />

####Switches

######CheckBox 2f4ef716b69c17fd0f540da4788b5dfa.png

android:id="@+id/checkBox"

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:background="#1E88E5"

materialdesign:check="true" />

######Switch switch.png

android:id="@+id/switchView"

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:background="#1E88E5"

materialdesign:check="true" />

####Progress indicators

######Progress bar circular indeterminate progress_bar_circular_indeterminate.png

android:id="@+id/progressBarCircularIndeterminate"

android:layout_width="32dp"

android:layout_height="32dp"

android:background="#1E88E5" />

######Progress bar indeterminate progress_bar_indeterminate.png

android:id="@+id/progressBarIndeterminate"

android:layout_width="fill_parent"

android:layout_height="wrap_content"

android:background="#1E88E5" />

######Progress bar indeterminate determinate progress_bar_indeterminate_determinate.png

android:id="@+id/progressBarIndeterminateDeterminate"

android:layout_width="fill_parent"

android:layout_height="wrap_content"

android:background="#1E88E5" />

If you begin progrees, you only have to set progress it

progressBarIndeterminateDeterminate.setProgress(progress);

######Progress bar determinate progress_bar_determinate.png

android:id="@+id/progressDeterminate"

android:layout_width="fill_parent"

android:layout_height="wrap_content"

android:background="#1E88E5" />

You can custom max and min progress values with materialdesign:max="50" and materialdesign:min="25" attributes.

######Slider slider.png

android:id="@+id/slider"

android:layout_width="fill_parent"

android:layout_height="wrap_content"

android:background="#1E88E5"

materialdesign:max="50"

materialdesign:min="0"

/>

######Slider with number indicator slider_with_number_indicator.png

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"/>

##Widgets

####SnackBar

snackbar.png

SnackBar snackbar = new SnackBar(Activity activity, String text, String buttonText, View.OnClickListener onClickListener);

snackbar.show();

If you don‘t want to show the button, put null in buttonText attribute

####Dialog

dialog.png

Dialog dialog = new Dialog(Context context,String title, String message);

dialog.show();

You can set the accept and cancel button on the event listener or change it‘s text

// 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();

####Color selector

color_selector.png

ColorSelector colorSelector = new ColorSelector(Context context,int intialColor, OnColorSelectedListener onColorSelectedListener);

colorSelector.show();

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值