android布局scrollview内部的linearlayout高度如何铺满容器
需要设置scrollview控件的fillViewport属性为true,此时scrollview内的控件layout_height设置为match_parent时,可以铺满容器
无法让图片铺满屏幕的代码
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
tools:context="com.rain.wldgg.singleweather.MainActivity"
tools:showIn="@layout/app_bar_main"
android:scrollbars="none">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<com.rain.wldgg.singleweather.customview.RainView
android:id="@+id/rainview"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@mipmap/rainweather"
app:rain_color="0xffff0000"
app:rain_number="2" />
</LinearLayout>
</ScrollView>
让图片铺满屏幕的代码
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
tools:context="com.rain.wldgg.singleweather.MainActivity"
tools:showIn="@layout/app_bar_main"
android:scrollbars="none"
android:fillViewport="true">//设置fillViewport属性为true
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<com.rain.wldgg.singleweather.customview.RainView
android:id="@+id/rainview"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@mipmap/rainweather"
app:rain_color="0xffff0000"
app:rain_number="2" />
</LinearLayout>
</ScrollView>