我有一個簡單的對話框,它只顯示兩個選項(「編輯」和「刪除」)。我在.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