我正在努力实现这样的目标:
- |-------------------|<-------Phone screen
| ||-----------------||
| || ||
80% || ||
| || ||
| || |<--------Image View (fills screen, background)
- |||---------------|||
| ||| |||
20% ||| |<---------Scroll View (starts after 80% of parent view)
| ||-----------------||
- |-------------------|
ImageView 有一个图像填充背景,scrollView 在高度的 80% 之后开始。有人可以帮助我了解如何在所有设备尺寸上实现这一目标吗?
最佳答案
使用layout_weight
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<View
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="8" />
<ScrollView
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="2">
</ScrollView>
</LinearLayout>
</RelativeLayout>
关于安卓 : Set scroll view position to start at 80% from top of screen,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18942964/