您不能查詢XML中的屏幕尺寸,因爲它在運行時不運行,您可以通過使用RelativeLayout
做到這一點,使用alignments
和margins
。
你的情況
如果SCREEN_HEIGHT橫幅代表了屏幕高度,你想它在底部位置,並從年底5DP分離器的XML將
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<ScrollView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:layout_marginBottom="5dp">
</RelativeLayout >
如果您需要縮放滾動視圖,而不是的位置它你xml將是
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:padding_bottom="5dp">
<ScrollView
android:layout_width="wrap_content"
android:layout_height="fill_parent">
</RelativeLayout >
API API Level 8及更高版本將「fill_parent」替換爲「match_parent」 – Antonin