android自定义尺寸单位,Android:自定义对话框尺寸错误

博主在尝试创建一个包含自定义视图的对话框,布局由两个垂直排列的LinearLayout组成,每个布局包含一个TextView和一个EditText。然而,对话框显示时宽度比预期要大,没有完全填充内容。博主已经尝试了使用LinearLayout代替RelativeLayout,以及直接设置对话框大小,但问题仍未解决。寻求解决方案以调整对话框的大小,使其适应内容。
摘要由CSDN通过智能技术生成

我正在尝试显示带有自定义视图的对话框。布局非常简单;基本上有两个LinearLayouts;每个布局的TextView和EditText。Android:自定义对话框尺寸错误

我使用的布局是这样的:

android:layout_width="wrap_content"

android:layout_height="wrap_content">

android:orientation="vertical"

android:layout_margin="5dip"

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:id="@+id/ll_element1">

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:text="Element 1"/>

android:layout_width="250dip"

android:layout_height="wrap_content"

android:lines="5"/>

android:orientation="vertical"

android:layout_margin="5dip"

android:layout_width="wrap_content"

android:layout_below="@id/ll_element1"

android:layout_height="wrap_content">

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:text="Element 2"/>

android:layout_width="250dip"

android:layout_height="wrap_content"

android:lines="5"/>

但是,如果我把它设置为视图对话框如下所示:

a0c6f8fd05b5f6dc1cfb83a3efe270a0.png

我的代码显示对话框是这样的:

var view = this.LayoutInflater.Inflate(Resource.Layout.Custom_Dialog, null);

var dialog = new AlertDialog.Builder(this)

.SetView(view)

.Create();

dialog.Show();

在我看来,对话框的宽度应该更小,以便布局填充对话框。 我已经试过几件事情:

使用的LinearLayout代替RelativeLayout的

设置explizit

二手对话,而不是AlertDialog

这样,我必须做的所有大小获得正确大小的对话框?

编辑 更新了图片

2012-08-23

Noffls

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值