changed the background of the button and stopped the action effect

Asked

Viewed 503 times

1

I changed the background of my button to #000000 (black) and stopped performing the click demonstration (turned blue when clicked)

<Button
   android:id="@+id/btNext2"
   android:layout_width="0dp"
   android:layout_height="match_parent"
   android:layout_weight="1"
   android:text="@string/Next"
   android:textSize="30sp"
   android:background="#000000"
   android:textColor="#ffffff"/>

1 answer

3

You need a selector in that background to have button states, not simply a solid color. Create a file btn_selector.xml in your directory drawable and do something like that:

<selector xmlns:android="http://schemas.android.com/apk/res/android">
    <item android:drawable="@android:color/darker_gray" android:state_pressed="true"/>
    <item android:drawable="@android:color/black"/>
</selector>

And on the estate background button:

android:background="@drawable/btn_selector"

Browser other questions tagged

You are not signed in. Login or sign up in order to post.