即使我让重心文字仍然在左边。我假设必须有一种方法来改变文本对齐 (我也尝试过android:textAlignment =“中心”太)左边的中心对齐按钮文字
我已经包括下面的屏幕截图,但没有足够的声望来显示它。
<!-- language: lang-xml-->
<Button
android:id="@+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="50"
android:gravity="center"
android:text="Button" />
也试图让它匹配_parent仍然是同样的问题。
EDIT对于整个XML
<!-- language: lang-xml-->
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<EditText
android:id="@+id/etCommands"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:hint="Type a Command"
android:password="true" >
</EditText>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:weightSum="100" >
<Button
android:id="@+id/button1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:text="Button" />
</LinearLayout>
<TextView
android:id="@+id/tvResults"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:text="invalid" />
</LinearLayout>
它的默认居中。 – Ahmad
是的,我知道这意味着我尝试过。 –
只要删除'android:gravity =“center”' – Ahmad