我的 Scrollview
在一些 layouts
下留出空间我是android新手,请帮助这里是我的代码:
<ScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/scrollviewdb"
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textSize="15sp"
android:padding="5dp"
android:id="@+id/ghavaed_text"/>
</LinearLayout>
</ScrollView>
最佳答案
添加 android:fillViewport
在您的 ScrollView 中。
<ScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/scrollviewdb"
android:fillViewport="true"
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textSize="15sp"
android:padding="5dp"
android:id="@+id/ghavaed_text"/>
</LinearLayout>
</ScrollView>
正如@Ironman 解释的那样,这背后的原因是,如果 ScrollView 的内容总是和它自己一样高,它就会变得毫无用处。要解决这个问题,您需要使用名为
android:fillViewport
的 ScrollView 属性。 .当设置为 true 时,如果需要,此属性会使 ScrollView 的 subview 扩展到 ScrollView 的高度。当child高于ScrollView时,该属性无效
关于android - scrollview 在布局 Activity 的底部留下额外的空间,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39244094/