2
I’m developing an Android app that’s basically a game. In one of the Activities there are some buttons, and I wanted that when an event occurred (including the trigger of another button) two buttons change position in the layout. I researched the documentation of the Transition class to see if it was possible to use an animation to make this change, but I really wanted something with a non-existent delay.
NOTE: Just changing the appearance of the buttons are not options for me, since each of these buttons have different functions within the application and I need to keep them.
<LinearLayout android:id="@+id/lytKeyboard"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_marginStart="15dp"
android:layout_marginEnd="15dp"
android:orientation="vertical">
<LinearLayout android:id="@+id/lytKeyboardLine1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<Button android:id="@+id/btn1"
android:layout_width="100dp"
android:layout_height="100dp"
android:text="1"
android:textSize="50sp"/>
<Button android:id="@+id/btn2"
android:layout_width="100dp"
android:layout_height="100dp"
android:text="2"
android:textSize="50sp"/>
<Button android:id="@+id/btn3"
android:layout_width="100dp"
android:layout_height="100dp"
android:text="3"
android:textSize="50sp"/>
</LinearLayout>
<LinearLayout android:id="@+id/lytKeyboardLine2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<Button android:id="@+id/btn4"
android:layout_width="100dp"
android:layout_height="100dp"
android:text="4"
android:textSize="50sp"/>
<Button android:id="@+id/btn5"
android:layout_width="100dp"
android:layout_height="100dp"
android:text="5"
android:textSize="50sp"/>
<Button android:id="@+id/btn6"
android:layout_width="100dp"
android:layout_height="100dp"
android:text="6"
android:textSize="50sp"/>
</LinearLayout>
<LinearLayout android:id="@+id/lytKeyboardLine3"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<Button android:id="@+id/btn7"
android:layout_width="100dp"
android:layout_height="100dp"
android:text="7"
android:textSize="50sp"/>
<Button android:id="@+id/btn8"
android:layout_width="100dp"
android:layout_height="100dp"
android:text="8"
android:textSize="50sp"/>
<Button android:id="@+id/btn9"
android:layout_width="100dp"
android:layout_height="100dp"
android:text="9"
android:textSize="50sp"/>
</LinearLayout>
<Button android:id="@+id/btn0"
android:layout_width="match_parent"
android:layout_height="100dp"
android:text="0"
android:textSize="50sp"/>
</LinearLayout>
Ask the layout xml question. When it says swap refers to the button 1 to the place of button 2 and button 2 to the place of button 1?
– ramaral
Yes, exactly
– Pablo Henrique