布局警告对话框与动态内容-结果太高



我很难压缩我的警告对话框来包装我的内容。对话框的布局XML结构如下:

+ linear layout (main)
++ text view
++ linear layout (placeholder)

我使用占位符附加一个单一的编辑文本派生字段到它以后,在oncreate期间,通过调用addView(),所以我的oncreate基本上看起来像这样:

View v = LayoutInflater.from(context).inflate(input_layout, null);
LinearLayout placeholder = (LinearLayout)view.findViewById(input_placeholder)
SoftEditText text = new SoftEditText(context)
// set text attributes - input type, ime action, watchers and listeners
placeholder.addView(text);
setCancelable(true);
setButton(BUTTON_NEGATIVE, ....);
setTitle(title_label);
// view.forceLayout() - didn't help much
setView(view);
super.onCreate(instance);
// getWindow().getAttributes().height=LayoutParams.WRAP_CONTENT no go either

,结果是:我的警告对话框的高度是它应该是两倍。我的linearlayout是设置为WRAP_CONTENT的高度,如果我画他们的背景,我看到他们是正确的大小(这是近一半的对话框的高度)。对话框的其余部分是黑色的,所以没有组件强制或期望这个大小。

我将文本的maxLines设置为1,但这再次没有帮助。这似乎是一个微不足道的布局问题,但我不知道我应该调用更多的对话框来简单地包装内容。

谢谢你的提示

设置maxLength,您可以使用ellipsize来指示延续文本。

相关内容

最新更新