I tried to research, but I can't make heads or tails because I'm so new to this.
I'm using Constrained layout. I have a button, button1. button1 has a bottom margin of 10.
Is there an easy way to make it so when I click my button, it changes bottom margin to 20?
This is my simple code:
button1.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
if (butt1){
button1.setBackgroundResource(buttonpress2);
butt1 = false;
}else{
button1.setBackgroundResource(buttonpress);
butt1 = true;
}
}
});
Also:
<Button
android:id="@+id/button1"
android:layout_width="50dp"
android:layout_height="50dp"
android:background="@drawable/buttonpress"
android:text="@string/button1Text"
android:textSize="24sp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
android:layout_marginBottom="10dp"
android:layout_marginLeft="38dp" />