At the moment I have a button in my view. What I want is that when it gets clicked that the buttonbackgroundcolor changes to an ARGB of 25,0,0,1 , meaning 25% opacity. It should be that color every time the user touches the button. So when it is not touched the button's background should be 100% transparent.
Here's my .xml
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/layout_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MyActivity2"
android:background="#ffdb4b5e">
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Next"
android:id="@+id/button"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true"
android:textColor="#ffffffff"
android:textSize="72sp"
android:background="#00000000"
/>
<TextView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="@string/thing1"
android:id="@+id/textView"
android:textColor="#ffffffff"
android:textSize="36sp"
android:gravity="center"
android:layout_above="@+id/button"
/>
</RelativeLayout>
onClick method:
n.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Random RAND = new Random();
int position = RAND.nextInt(colors.length);
int position2 = (index++);
String nextValue = colors[position];
String textValue = values[position2];
tv.setText(textValue);
rl.setBackgroundColor(Color.parseColor(nextValue));
n.setBackgroundColor(Color.argb(25,0,0,1));
}
});
}
as you can see I already set the background to 25,0,0,1. The problem is though that when the button gets pressed the color changes permanently to 25,0,0,1...