Ticker

6/recent/ticker-posts

Create custom color button, in Android Studio


To create custom buton, create a XML file under drawable folder.


drawable/colorbutton.xml




android:angle="90"
android:endColor="#000050"
android:startColor="#0000E0" />
android:width="3dp"
android:color="#303030" />
android:radius="10dp" />
android:bottom="10dp"
android:left="10dp"
android:right="10dp"
android:top="10dp" />





android:angle="270"
android:endColor="#500000"
android:startColor="#E00000" />
android:width="3dp"
android:color="#303030" />
android:radius="10dp" />
android:bottom="10dp"
android:left="10dp"
android:right="10dp"
android:top="10dp" />





android:angle="270"
android:endColor="#005050"
android:startColor="#00E0E0" />
android:width="3dp"
android:color="#303030" />
android:radius="10dp" />
android:bottom="10dp"
android:left="10dp"
android:right="10dp"
android:top="10dp" />




Use it in layout file, layout/activity_main.xml
    xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:padding="10dp"
tools:context=".MainActivity">

android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:autoLink="web"
android:text="http://picturedmagazine.blogspot.com/"
android:textStyle="bold" />

android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Color Button"
android:background="@drawable/colorbutton"
android:textColor="@android:color/white"/>





How to do it in Android Studio:




Related:
- Android pre-defined Button style - buttonStyle, borderlessButtonStyle, buttonStyleToggle and buttonStyleInset

إرسال تعليق

0 تعليقات