Material Designer's low version compatible implementations (eight)--buttonflat

Source: Internet
Author: User

In addition to the well-behaved rectangular buttons, the 5.0 flattened the button, resulting in a flat button--flat. This button reduces a lot of presence, mainly used in the dialog box, the prompt bar. Let the entire interface reduce the level. Today's talk is about its usage.

This button inherits from the Rectangle button, so there are many properties of the rectangle button, please see an article about the rectangle button.

The first is to add the Lib dependency. LIB Address:https://github.com/shark0017/MaterialDesignLibrary

First, put the layout file

Custom namespaces:xmlns:app= "Http://schemas.android.com/apk/res-auto"

< Com.gc.materialdesign.views.ButtonFlat                 Android:layout_width = "Wrap_content"                 android:layout_height= "wrap_content"/>

It is now the default mode and does not have any settings. The default condition is a button that is completely transparent

Ii. setting various properties in the layout file

android:background= "@color/orange" sets the background color, which is transparent by default

android:text= "Flat button" to set text with no text by default

Android:textsize= "20SP" to set the text size, default 14SP, text is bold.

Android:textcolor= "#ffc641" to set the text color, default is blue

App:ripplecolor= "#ffc641" sets the color of the ripple, which is gray by default

App:ripplespeed= "2" Set ripple spread speed, default 6f

App:clickafterripple= "False" sets the time at which the click event is triggered, by default the ripple is spread out and then the starting point hit event

Three, through the code to set various properties

 Public classButtonflattestextendsactionbaractivity {@Overrideprotected voidonCreate (Bundle savedinstancestate) {Super. OnCreate (savedinstancestate);                Setcontentview (R.layout.button_flat); Btn01.setbackgroundcolor (Getresources (). GetColor (R.color.orange));//Set Button BackgroundBtn02.setbackgroundcolor (0xffff0000);//Set Button BackgroundBtn03.settext ("SetText");//Set Button textBtn04.settextsize (30);//Set Text SizeBtn05.settextcolor (0xffffc641);//Set Text colorBtn06.settextcolor (Getresources (). GetColor (r.color.red));//set text color by resourceBtn07.setripplecolor (0xffffc641);//set the color value directlyBtn08.setripplecolor (Getresources (). GetColor (R.color.orange));//set the color of the ripplesBtn09.setripplespeed (2);//set ripple spread speedBtn10.setclickafterripple (false);//Create click event immediately after settingButtonflat.gettextview ();//get the TextView object in this button to make various settings    }}

Material Designer's low version compatible implementations (eight)--buttonflat

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.