And*_*Dev 0 android android-layout android-scrollview
我有一个相对布局填满整个屏幕.我想在它的中间添加一个scrollview来包装一堆内容,这样我就可以在显示软键盘时使其平移.但是,只要我将其包装在滚动视图中,最底部的布局就会停止填充屏幕的其余部分.
这是我ScrollView注释掉的XML .
<include
android:id="@+id/top_bar_with_save_button"
layout="@layout/top_bar_with_save_button"/>
<FrameLayout
android:id="@+id/log_entry_title_frame"
android:layout_below="@id/top_bar_with_save_button"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@id/log_entry_title_frame"
android:layout_alignParentBottom="true">
<!--
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent">
-->
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@+id/log_entry_title_frame"
android:orientation="vertical"
android:background="#f00">
<!-- Lots of stuff in here -->
<EditText
android:id="@+id/log_entry_notes"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="8dp"
android:gravity="top|left"/>
</RelativeLayout>
<!--
</ScrollView>
-->
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)
它看起来像这样:
但是一旦我删除它的评论ScrollView立即压缩如下:
为什么会这样?我需要它来填充屏幕上的整个空间,我无法弄清楚发生了什么.谁能告诉我如何解决这个问题?谢谢!
您需要将fillViewport="true"属性添加到ScrollView标记中.或者您可以通过编程方式添加它scrollView.setFillViewPort(true);.否则,ScrollView将换行到其子级的内容高度.
| 归档时间: |
|
| 查看次数: |
552 次 |
| 最近记录: |