Android ScrollView無法填充滿屏幕的解決辦法
ScrollView滾動視圖是指當擁有很多內(nèi)容、屏幕顯示不完時、需要通過滾動跳來顯示的視圖、Scrollview的一般用法如下
以下代碼在Scrollview里面放了一個RelativeLayout、并且是設(shè)置為Android:layout_height="match_parent"填充全屏的和RelativeLayout里面放置了一個TextView背景設(shè)為了一張圖片、按照代碼理解、圖片應(yīng)該是居于屏幕的最下方的
<ScrollView android:layout_width="match_parent" android:layout_height="match_parent" > <RelativeLayout android:layout_width="match_parent" android:layout_height="match_parent" android:background="@color/common_background" > <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_centerHorizontal="true" android:layout_alignParentBottom="true" android:background="@drawable/bottom_bg" /> </RelativeLayout></ScrollView>
但是最后運行的效果是這樣的、你會發(fā)現(xiàn)圖片并沒有局到整個屏幕的下邊、而是在上面ScrollView無法填充滿屏幕,

那么要怎么解決這個問題呢、最后我在查看文檔的時候發(fā)現(xiàn)了這樣一個屬性、設(shè)置了就可以解決這個問題了
<ScrollView android:layout_width="match_parent" android:layout_height="match_parent" android:fillViewport="true" ></ScrollView>
也就是說設(shè)置ScrollView的android:fillViewport為true、即 android:fillViewport="true"即可。
新聞熱點
疑難解答
圖片精選