我有一个简单的对话框,它只显示两个选项(“编辑”和“删除”)。我在.xml文件中将其布局设置为在属性中指定给定的宽度。但是,在应用程序中,它看起来像设置“wrap_content”一样窄。它足够宽以包装文本。我怎么能解决这个问题?可能我错过了一些非常简单的事情。这里的XML代码提前自定义对话框似乎没有设置宽度
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/dialog"
android:layout_width="350dp"
android:layout_height="wrap_content"
android:orientation="vertical" >
<TextView
android:id="@+id/editOption"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="16dp"
android:layout_marginLeft="6dp"
android:layout_marginRight="6dp"
android:layout_marginTop="16dp"
android:text="@string/edit"
android:textAlignment="center"
android:textColor="@color/colorPrimaryText"
android:textSize="@dimen/text_size" />
<TextView
android:id="@+id/deleteOption"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="20dp"
android:layout_marginLeft="6dp"
android:layout_marginRight="6dp"
android:layout_marginTop="20dp"
android:text="@string/delete"
android:textAlignment="center"
android:textColor="@color/colorPrimaryText"
android:textSize="@dimen/text_size" />
</LinearLayout>
感谢
这只是足够宽,以换行。我怎么能解决这个问题?你希望文字垂直或水平对齐..? –
垂直,我的意思是,一个在另一个之下。 – paola91