Material設計Android庫:Material Design Android Library
如果你想使用這個庫,你只需要下載MaterialDesign項目,將其導入到您的工作區,并作為android項目庫添加到你的設置中。
有些組件自定義屬性,如果你想使用它們,你必須在第一個組件XML文件中加入這一行:
<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"
>
</RelativeLayout>如果你要使用一個滾動,則建議您使用這個庫提供的CustomScrollView,以避免自定義組件的問題。要使用這個組件:<com.gc.materialdesign.views.ScrollView 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"> </com.gc.materialdesign.views.ScrollView>
Components
Buttons
Flat Button
<com.gc.materialdesign.views.ButtonFlat
android:id="@+id/buttonflat"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#1E88E5"
android:text="Button" /> Rectangle Button
<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" /> 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.
</blockquote><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>Float small button
<com.gc.materialdesign.views.ButtonFloatSmall android:id="@+id/buttonFloatSmall" android:layout_width="wrap_content" android:layout_height="wrap_content" android:background="#1E88E5" materialdesign:icon="@drawable/ic_action_new" />Switches
CheckBox
<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
<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" />Progress indicators
Progress bar circular indeterminate
<com.gc.materialdesign.views.ProgressBarCircularIndetermininate android:id="@+id/progressBarCircularIndetermininate" android:layout_width="32dp" android:layout_height="32dp" android:background="#1E88E5" />Progress bar indeterminate
<com.gc.materialdesign.views.ProgressBarIndeterminate android:id="@+id/progressBarIndeterminate" android:layout_width="fill_parent" android:layout_height="wrap_content" android:background="#1E88E5" />Progress bar indeterminate determinate
<com.gc.materialdesign.views.ProgressBarIndeterminateDeterminate 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
</blockquote>progressBarIndeterminateDeterminate.setProgress(progress);Progress bar determinate
<com.gc.materialdesign.views.ProgressBarDetermininate 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
</blockquote>materialdesign:max="50"andmaterialdesign:min="25"attributes.Slider
<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" />Slider with number indicator
<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"/>Widgets
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
</blockquote>nullinbuttonTextattributeDialog
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();</blockquote>Color selector
ColorSelector colorSelector = new ColorSelector(Context context,int intialColor, OnColorSelectedListener onColorSelectedListener); colorSelector.show();https://github.com/navasmdc/MaterialDesignLibrary
本文由用戶 jopen 自行上傳分享,僅供網友學習交流。所有權歸原作者,若您的權利被侵害,請聯系管理員。
轉載本站原創文章,請注明出處,并保留原始鏈接、圖片水印。
本站是一個以用戶分享為主的開源技術平臺,歡迎各類分享!














