我已经搜索了如何将应用程序对齐到右侧以及从右到左写入的文本。
我发现并成功做的唯一一件事是通过添加 EditText 和 Button 使文本从右到左书写android:gravity="right"
,但如果从左到右,它们仍然在行中排序。
activity_main.xml 文件 -
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:gravity="right"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="horizontal" >
<EditText android:id="@+id/text_message"
android:gravity="right"
android:layout_weight="1.0"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:hint="@string/text_message" />
<Button android:layout_height="wrap_content"
android:gravity="right"
android:layout_width="wrap_content"
android:text="@string/send_button"
android:onClick="ButtonClicked" />
<Button android:layout_height="wrap_content"
android:gravity="right"
android:layout_width="wrap_content"
android:text="@string/delete_button"
android:onClick="DeleteClicked" />
</LinearLayout>
我在“排序是从左到右”的意思是 EditText 写在“发送”按钮之前,而“发送”按钮 id 写在“删除”按钮之前 - 所以显示的是
“[ _ ___ x ] [Send][Delete]" 而不是 "[Delete][Send][ _ ____ ]",就像我想要的那样。