热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

Material设计Android库:MaterialDesignAndroidLibrary

如果你想使用这个库,你只需要下载MaterialDesign项目,将其导入到您的工作区,并作为android项目库添加到你的设置中。


如果你想使用这个库,你只需要下载MaterialDesign项目,将其导入到您的工作区,并作为android项目库添加到你的设置中。

有些组件自定义属性,如果你想使用它们,你必须在第一个组件XML文件中加入这一行:

xmlns:materialdesign="http://schemas.android.com/apk/res-auto"
android:layout_
android:layout_
>
如果你要使用一个滚动,则建议您使用这个库提供的CustomScrollView,以避免自定义组件的问题。要使用这个组件:

xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:materialdesign="http://schemas.android.com/apk/res-auto"
android:id="@+id/scroll"
android:layout_
android:layout_>

Components


Buttons


Flat Button

flat button

android:id="@+id/buttonflat"
android:layout_
android:layout_
android:background="#1E88E5"
android:text="Button" />

Rectangle Button

rectangle button

android:id="@+id/button"
android:layout_
android:layout_
android:background="#1E88E5"
android:text="Button" />

Float Button

float button

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_
android:layout_
>

android:id="@+id/buttonFloat"
android:layout_
android:layout_
android:layout_alignParentRight="true"
android:layout_alignParentBottom="true"
android:layout_marginRight="24dp"
android:background="#1E88E5"
materialdesign:animate="true"
materialdesign:icon="@drawable/ic_action_new" />

Float small button

float small button

android:id="@+id/buttonFloatSmall"
android:layout_
android:layout_
android:background="#1E88E5"
materialdesign:icon="@drawable/ic_action_new" />

Switches


CheckBox

checkbox

android:id="@+id/checkBox"
android:layout_
android:layout_
android:background="#1E88E5"
materialdesign:check="true" />

Switch

switch

android:id="@+id/switchView"
android:layout_
android:layout_
android:background="#1E88E5"
materialdesign:check="true" />

Progress indicators


Progress bar circular indeterminate

progress bar circular indeterminate

android:id="@+id/progressBarCircularIndetermininate"
android:layout_
android:layout_
android:background="#1E88E5" />

Progress bar indeterminate

progress bar indeterminate

android:id="@+id/progressBarIndeterminate"
android:layout_
android:layout_
android:background="#1E88E5" />

Progress bar indeterminate determinate

Progress bar indeterminate determinate

android:id="@+id/progressBarIndeterminateDeterminate"
android:layout_
android:layout_
android:background="#1E88E5" />

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

progressBarIndeterminateDeterminate.setProgress(progress);



Progress bar determinate

Progress bar determinate

android:id="@+id/progressDeterminate"
android:layout_
android:layout_
android:background="#1E88E5" />

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


Slider

Slider

android:id="@+id/slider"
android:layout_
android:layout_
android:background="#1E88E5"
materialdesign:max="50"
materialdesign:min="0"
/>

Slider with number indicator

Slider with number indicator

android:id="@+id/slider"
android:layout_
android:layout_
android:background="#1E88E5"
materialdesign:max="50"
materialdesign:min="0"
materialdesign:showNumberIndicator="true"/>

Widgets


SnackBar

Snackbar

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

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

ColorSelector colorSelector = new ColorSelector(Context context,int intialColor, OnColorSelectedListener onColorSelectedListener);
colorSelector.show();https://github.com/navasmdc/MaterialDesignLibrary


推荐阅读
author-avatar
超级神棍小虾米
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有