如何在每个屏幕大小上显示滚动活动的固定部分?我有一个可滚动活动的活动,其中包含一个pageViewer,在下面是4个按钮。在平均屏幕上,它仅显示这些内容,其余的位于屏幕下方,这意味着在按钮下方还有更多视图。如果我们使用较宽的屏幕,则这些视图在滚动之前也会出现在主视图中。我需要使所有屏幕尺寸的视图范围相同,这也意味着更宽的屏幕,我只需要查看pageViewer和按钮,其余才能在我们滚动时才能看到。
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/idd_parent"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<ScrollView
android:id="@+id/scrollView"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:weightSum="1">
<android.support.v4.view.ViewPager
android:id="@+id/viewPager"
android:layout_width="match_parent"
android:layout_height="500dp" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:weightSum="1">
<Button
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="0.25"
android:text="Button1" />
<Button
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="0.25"
android:text="Button1" />
<Button
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="0.25"
android:text="Button1" />
<Button
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="0.25"
android:text="Button1" />
</LinearLayout>
<TextView
android:layout_width="match_parent"
android:layout_height="50dp"
android:text="other view" />
<TextView
android:layout_width="match_parent"
android:layout_height="50dp"
android:text="other view" />
<TextView
android:layout_width="match_parent"
android:layout_height="50dp"
android:text="other view" />
<TextView
android:layout_width="match_parent"
android:layout_height="50dp"
android:text="other view" />
<TextView
android:layout_width="match_parent"
android:layout_height="50dp"
android:text="other view" />
</LinearLayout>
</ScrollView>
</LinearLayout>
以编程方式设置ViewPager高度,以便它可以匹配移动高度