Tôi đang cố gắng tạo một Hộp thoại tùy chỉnh và đặt nội dung của nó ở giữa, nhưng nó luôn luôn kết thúc bằng căn trái. Dưới đây là aboutdialog.xml:Làm thế nào để bố trí trung tâm bên trong của Android Dialog?
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:a="http://schemas.android.com/apk/res/android"
a:orientation="vertical"
a:id="@+id/AboutDialogLayout"
a:layout_width="fill_parent"
a:layout_height="fill_parent"
a:layout_gravity="center_horizontal"
a:gravity="center_horizontal">
<ImageView a:id="@+id/imageView1"
a:src="@drawable/pricebook"
a:layout_height="wrap_content"
a:layout_width="wrap_content"/>
<TextView a:layout_height="wrap_content"
a:textAppearance="?android:attr/textAppearanceLarge"
a:id="@+id/textView1"
a:text="Price Book"
a:layout_width="wrap_content"/>
<TextView a:layout_height="wrap_content"
a:id="@+id/textView2"
a:layout_width="wrap_content"
a:text="foo"/>
</LinearLayout>
Và tôi (có liên quan) Mã:
Dialog d = new Dialog(this);
d.setContentView(R.layout.aboutdialog);
d.setTitle(R.string.app_name);
tôi thiếu gì ở đây? Cảm ơn sự hỗ trợ.
Ảnh:
Thật kỳ lạ. Việc này ổn với tôi. Bạn có thể gửi ảnh chụp màn hình? – inazaruk
+1 để sử dụng: thay vì android: ở khắp mọi nơi, bạn đã làm như thế nào? –
Có, tôi cũng kiểm tra xem nó hoạt động tốt. –