如何Android的对话里集中布局?布局、Android

由网友(一推敲)分享简介:我想创建一个自定义对话框,并对其内容为中心,但它始终是结束了左对齐。这里是aboutdialog.xml:I am trying to create a custom Dialog, and have its content centered, but it is always ending up left-alig...

我想创建一个自定义对话框,并对其内容为中心,但它始终是结束了左对齐。这里是aboutdialog.xml:

I am trying to create a custom Dialog, and have its content centered, but it is always ending up left-aligned. Here is aboutdialog.xml:

<?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>

和我的(相关)code:

And my (relevant) code:

Dialog d = new Dialog(this);
d.setContentView(R.layout.aboutdialog);
d.setTitle(R.string.app_name);

我在想什么吗?感谢您的帮助。

What am I missing here? Thanks for the assistance.

图片:

Image:

推荐答案

尝试编辑这样: A:layout_gravity =center_horizo​​ntal | center_vertical 或 使用Relative_Layout和对齐于母公司的中心线性布局 FILL_PARENT 相对 WRAP_CONTENT 的直线。

try to edit to this: a:layout_gravity="center_horizontal|center_vertical" OR use Relative_Layout and align linear layout to center of parent with fill_parent for Relative wrap_content for Linear.

尽管它与我中心工作的

阅读全文

相关推荐

最新文章