您好,我正在 android studio 中制作西洋跳棋游戲,當我將其下載到手機時,我的棋盤按鈕順序會發生變化。
來自 android studios 模擬器的圖片:
它在我的手機中的外觀:
我手機上的所有線路都顛倒了
我的xml代碼:
<?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>
我只放了一條線,因為它只是重復自己 8 次來創建板。
uj5u.com熱心網友回復:
這是因為您的手機使用的是 RTL 語言。要強制它布局 LTR,請添加android:layoutDirection="ltr"到水平線性布局(全部 8 個)。
轉載請註明出處,本文鏈接:https://www.uj5u.com/shujuku/487689.html
