hello i am making a checkers game in android studio and my board buttons order changes when i download it to my phone.
image from android studios emulator:
all lines are reversed on my phone
my xml code:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:layout_gravity = "center"
tools:context=".MainActivity">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<ImageButton
android:id="@ id/box0"
android:layout_width="48dp"
android:layout_height="48dp"
android:layout_weight="1"
android:background="@drawable/white"
android:foreground="@drawable/redchecker"
tools:ignore="SpeakableTextPresentCheck" />
<ImageButton
android:id="@ id/box1"
android:layout_width="48dp"
android:layout_height="48dp"
android:layout_weight="1"
android:background="#000000"
tools:ignore="SpeakableTextPresentCheck" />
<ImageButton
android:id="@ id/box2"
android:layout_width="48dp"
android:layout_height="48dp"
android:layout_weight="1"
android:background="@drawable/white"
android:foreground="@drawable/redchecker"
tools:ignore="SpeakableTextPresentCheck" />
<ImageButton
android:id="@ id/box3"
android:layout_width="48dp"
android:layout_height="48dp"
android:layout_weight="1"
android:background="#000000"
tools:ignore="SpeakableTextPresentCheck" />
<ImageButton
android:id="@ id/box4"
android:layout_width="48dp"
android:layout_height="48dp"
android:layout_weight="1"
android:background="@drawable/white"
android:foreground="@drawable/redchecker"
tools:ignore="SpeakableTextPresentCheck" />
<ImageButton
android:id="@ id/box5"
android:layout_width="48dp"
android:layout_height="48dp"
android:layout_weight="1"
android:background="#000000"
tools:ignore="SpeakableTextPresentCheck" />
<ImageButton
android:id="@ id/box6"
android:layout_width="48dp"
android:layout_height="48dp"
android:layout_weight="1"
android:background="@drawable/white"
android:foreground="@drawable/redchecker"
tools:ignore="SpeakableTextPresentCheck" />
<ImageButton
android:id="@ id/box7"
android:layout_width="48dp"
android:layout_height="48dp"
android:layout_weight="1"
android:background="#000000"
tools:ignore="SpeakableTextPresentCheck" />
</LinearLayout>
ive put only one line because it just repets itself 8 times to create the board.
CodePudding user response:
This is because your phone is in a RTL language. To force it to layout LTR, add android:layoutDirection="ltr"
to the horizontal linear layout (all 8 of them).