Monday, January 12, 2015

How to create a transparent background Button in Android

activity_main.xml code snippet

<LinearLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    android:layout_gravity="left"
    android:layout_margin="15dp"
    android:background="#7B68EE"
    tools:context=".MainActivity"
    >
    <!--@null remove background and make the button transparent-->
    <Button
        android:id ="@+id/push_button"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Button Background Transparent"
        android:background="@null"
        android:padding="15dp"
        />
</LinearLayout>
More android examples