Java 启动应用程序时,我的应用程序对齐有问题
当我在我的设备上启动我的应用程序时,所有东西都按从右到左的顺序排列,但当我在模拟器上启动它时,它保持原样。我知道问题是我的设备的主要语言是希伯来语(希伯来语是一种从右向左书写的语言),模拟器的语言是英语 图1 图2 我希望它在所有语言中都是一样的 提前谢谢Java 启动应用程序时,我的应用程序对齐有问题,java,android,android-layout,Java,Android,Android Layout,当我在我的设备上启动我的应用程序时,所有东西都按从右到左的顺序排列,但当我在模拟器上启动它时,它保持原样。我知道问题是我的设备的主要语言是希伯来语(希伯来语是一种从右向左书写的语言),模拟器的语言是英语 图1 图2 我希望它在所有语言中都是一样的 提前谢谢 <?xml version="1.0" encoding="utf-8"?> <android.support.constraint.ConstraintLayout xmlns:android="http://sch
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout
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"
tools:context="com.example.mahmood.morsecode.TextToMorse">
<EditText
android:id="@+id/editText"
android:layout_width="0dp"
android:layout_height="180dp"
android:layout_marginEnd="8dp"
android:layout_marginStart="8dp"
android:layout_marginTop="8dp"
android:ems="10"
android:inputType="textMultiLine"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<EditText
android:id="@+id/editText2"
android:layout_width="0dp"
android:layout_height="180dp"
android:layout_marginBottom="80dp"
android:layout_marginEnd="8dp"
android:layout_marginStart="8dp"
android:ems="10"
android:inputType="textMultiLine"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintStart_toStartOf="parent" />
<LinearLayout
android:layout_width="344dp"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
android:layout_marginEnd="8dp"
android:layout_marginStart="8dp"
android:orientation="horizontal"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent">
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="BackSpace" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Button" />
<Button
android:id="@+id/button7"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Space" />
</LinearLayout>
</android.support.constraint.ConstraintLayout>
浏览您的布局,将
开始
更改为左侧
,将结束
更改为右侧
,例如,在您有布局的地方
更改为布局
这样做会将布局更改为
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout
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"
tools:context="com.example.mahmood.morsecode.TextToMorse">
<EditText
android:id="@+id/editText"
android:layout_width="0dp"
android:layout_height="180dp"
android:layout_marginRight="8dp"
android:layout_marginLeft="8dp"
android:layout_marginTop="8dp"
android:ems="10"
android:inputType="textMultiLine"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<EditText
android:id="@+id/editText2"
android:layout_width="0dp"
android:layout_height="180dp"
android:layout_marginBottom="80dp"
android:layout_marginRight="8dp"
android:layout_marginLeft="8dp"
android:ems="10"
android:inputType="textMultiLine"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintLeft_toLeftOf="parent" />
<LinearLayout
android:layout_width="344dp"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
android:layout_marginRight="8dp"
android:layout_marginLeft="8dp"
android:orientation="horizontal"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintLeft_toLeftOf="parent">
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="BackSpace" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Button" />
<Button
android:id="@+id/button7"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Space" />
</LinearLayout>
</android.support.constraint.ConstraintLayout>
检查您的AndroidManifest.xml
。默认情况下,Android Studio会将此属性添加到中,您的代码在哪里?目前还没有代码,问题出在布局中。我过去没有这个问题,它在我获得Android Studio 3.0(我认为是最新版本)时显示“还没有代码,问题出在布局中”。。。。布局是用代码创建的我编辑了这篇文章,很抱歉给您带来不便,我认为代码并不重要,因为昨天不是这样,我使用的是相同的应用程序和代码这些变量不接受(左,右…),或者我没有正确输入它们。我在正确的属性中输入它们。在Android Studio中打开XML上的查找并替换
(我想是Ctrl+R),查找开始
并将所有内容替换为左侧
,然后将所有结束
替换为右侧
。这就是我的意思。或者只使用我发布的版本。我使用了两种方法,但仍然是一样的:(嗯,那很简单。非常感谢
android:supportsRtl="true"