Tôi có một hộp thoại tùy chỉnh với một bố cục như thế này:thoại tùy chỉnh Android với scrollview đẩy nút tắt màn hình
<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>
Vấn đề của tôi là scrollview là khi có quá nhiều văn bản trong scrollview, các các nút dưới đây được đẩy ra khỏi hộp thoại. Tôi đã có thể ngăn chặn nó bằng cách neo RelativeLayout có chứa các nút ở phía dưới bằng cách sử dụng android: layout_alignParentBottom = "true", nhưng tôi kéo dài toàn bộ hộp thoại đến cuối màn hình khi có ít văn bản trong scrollview và Tôi không muốn điều đó.
Làm thế nào tôi có thể nhận được một bố cục như thế này:
[SOME TEXT]
[Scrollable region]
[Buttons]
Thử khắc phục sự chiều cao của bố cục chính như 300dip –
Tôi không muốn để sửa chiều cao của bố trí chính vì nó cần phải được thay đổi kích thước trên kích thước màn hình khác nhau và định hướng –