的Android定制对话框按下按钮关闭屏幕
我有这样的布局定制对话框:的Android定制对话框按下按钮关闭屏幕
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/mylayout">
<LinearLayout
android:id="@+id/title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView ... />
<TextView .../>
</LinearLayout>
<ScrollView
android:id="@+id/scrollView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/title">
<LinearLayout ...>
<TextView ...
android:text="lots of text........" />
<TextView .../>
</LinearLayout>
</ScrollView
<RelativeLayout ...
android:layout_below="@+id/scrollView">
<Button ...>
<Button ...>
</RelativeLayout>
</RelativeLayout>
我的问题是,滚动型的是,当在滚动视图太多的文字中,下面的按钮被压出对话框。我已经能够通过使用android:layout_alignParentBottom =“true”将包含按钮的RelativeLayout锚定到底部来阻止它,但是当scrollview中的文本较少时,我会将整个对话框拉伸到屏幕底部,并且我不想那样。
我怎样才能得到一个布局是这样的:
[SOME TEXT]
[Scrollable region]
[Buttons]
尝试LinearLayout
代替RelativeLayout
把按钮放在一个单独的布局,并把重量上的按钮布局。
LinearLayout - top level start, android:layout_weight="0"
LinearLayout with TextViews embeded, android:layout_weight="1"
LinearLayout with ScrollView embeded, android:layout_weight="1"
LinearLayout with Buttons embeded, android:layout_weight="1"
LinearLayout - top level finish, android:layout_weight="0"
即使用户使用的线性布局容器调整大小一个重量= 1的属性,按钮仍然被压下并在中途切断。所以它稍好些,但不是一个完整的解决方案... –
也将顶层布局更改为'LinearLayout'。然后有这样的东西:更新我发布它的答案... – Gix
嗯...没有运气,对话仍然延伸到屏幕之外,并推动按钮,所以他们被切断了一半。我的按钮和文字有一些边距,它们是否会影响布局计算? –
即使问题是慈祥的老人在这里是我的情况是什么帮助。希望这可以帮助别人,因为我花了相当长的一段时间来跟踪。
alertDialogBuilder.setMessage(null);
提问有关自定义对话框的问题,而不是警报对话框。 – Pkmmte
尝试修复主要布局在像300dip –
的高度我并不想解决的主要布局的高度,因为它需要在不同屏幕尺寸和方向 –