Eri*_*_DA 4 android android-layout android-scrollview
我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>
Run Code Online (Sandbox Code Playgroud)
添加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>
Run Code Online (Sandbox Code Playgroud)
正如@Ironman 所解释的,这背后的原因是,如果 ScrollView 的内容总是和它本身一样高,它就会变得毫无用处。要解决此问题,您需要使用名为 的 ScrollView 属性android:fillViewport。当设置为 true 时,如果需要,此属性会导致滚动视图的子级扩展到 ScrollView 的高度。当child比ScrollView高时,该属性没有作用
| 归档时间: |
|
| 查看次数: |
4819 次 |
| 最近记录: |