[关闭]
@cxm-2016 2016-08-29T15:16:15.000000Z 字数 887 阅读 1533

Flat Button

android no


How to add?

I. In your build.gradle add latest appcompat library.

  1. dependencies {
  2. compile 'com.android.support:appcompat-v7:X.X.X' // where X.X.X version
  3. }

II. Make your activity extend android.support.v7.app.AppCompatActivity.

  1. public class MainActivity extends AppCompatActivity {
  2. ...
  3. }

III. Declare your Button inside any layout.xml file with Borderless style.

  1. <Button
  2. android:layout_width="wrap_content"
  3. android:layout_height="wrap_content"
  4. android:text="Button"
  5. style="@style/Widget.AppCompat.Button.Borderless"/>

How to style?

I. Declare custom style in your styles.xml file.

  1. <style name="MyButton" parent="Theme.AppCompat.Light">
  2. <item name="colorControlHighlight">@color/pink</item>
  3. </style>

III. Apply this style to your Button via android:theme attribute.

  1. <Button
  2. android:layout_width="wrap_content"
  3. android:layout_height="wrap_content"
  4. android:text="Button"
  5. android:theme="@style/MyButton"
  6. style="@style/Widget.AppCompat.Button.Borderless"/>
添加新批注
在作者公开此批注前,只有你和作者可见。
回复批注