我正在制作一个安卓问答游戏,当用户点击一个按钮时,我希望能够将其突出显示,但当用户松开按钮后,它会恢复原来的颜色。你知道吗,我已经在按钮的背景中设置了圆角,我是在drawable中设置的。
<Button
android:id="@+id/btn1"
android:background="@drawable/roundedbutton"
android:textColor="#ffffff"
android:textStyle="italic"
android:layout_width="225sp"
android:layout_marginTop="23sp"
android:layout_height="38sp"
android:layout_alignLeft="@+id/btn2"
android:layout_below="@+id/textView1"
android:text="Button" />
圆形按钮.xml
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle" android:padding="10dp">
<solid android:color="#848482"/> <!-- this one is ths color of the Rounded Button -->
<corners
android:bottomRightRadius="6.5dp"
android:bottomLeftRadius="6.5dp"
android:topLeftRadius="6.5dp"
android:topRightRadius="6.5dp"/>
</shape>