我正在开发一个Ui设计,我必须设计一个完全可滚动的视图。在这个视图中,我有一个视图寻呼机和一个固定的页脚在底部,但当用户在垂直方向滚动内容时,这个页脚也会滚动。现在这里的页脚有很长的描述,但是如果没有滚动就不能看到它。在水平方向滚动时,视图寻呼机将工作,并且页脚似乎固定在底部。
这是我的代码。
<ScrollView
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:fillViewport="true" >
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<LinearLayout
android:id="@+id/linearLayoutFooter"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_margin="12dp"
android:orientation="vertical" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="12dp"
android:orientation="horizontal"
android:weightSum="100" >
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="80"
android:text="some dummy textl and Prevention"
android:textSize="12dp" />
<ImageView
android:id="@+id/imageviewViewExpander"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical|center_horizontal"
android:layout_weight="20"
android:src="@drawable/page_circle_arrow_down" />
</LinearLayout>
<TextView
android:id="@+id/textveiw"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="15dp"
android:text="some dummy textsome dummy textsome dummy textsome dummy text\nsome dummy textsome dummy textsome dummy textsome dummy textsome dummy textsome dummy text\nsome dummy textsome dummy textsome dummy textsome dummy textsome dummy text\nsome dummy textsome dummy textsome dummy textsome dummy text" >
</TextView>
</LinearLayout>
<android.support.v4.view.ViewPager
android:id="@+id/pager"
android:layout_width="match_parent"
android:layout_height="fill_parent"
android:layout_above="@id/linearLayoutFooter"
android:layout_alignParentTop="true" >
</android.support.v4.view.ViewPager>
</RelativeLayout>
</ScrollView>
这里的问题是我必须将页脚粘在底部,除非用户滚动,甚至视图分页器内容都不可见。
答案 0 :(得分:0)
我认为您可以在scrollview
之后RelativeLayout
之前放置LinearLayout
像这样:
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<!--here-->
<ScrollView
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:fillViewport="true" >
<LinearLayout
android:id="@+id/linearLayoutFooter"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_margin="12dp"
android:orientation="vertical" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="12dp"
android:orientation="horizontal"
android:weightSum="100" >
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="80"
android:text="Content courtesy of Centers for Disease Control and Prevention"
android:textSize="12dp" />
<ImageView
android:id="@+id/imageviewViewExpander"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical|center_horizontal"
android:layout_weight="20"
android:src="@drawable/page_circle_arrow_down" />
</LinearLayout>
<TextView
android:id="@+id/textViewDiseaseControl"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="15dp"
android:text="To help recognize a concussion, you should watch for and ask others to report the following two things among your athletes:\n\nA forceful bump, blow, or jolt to the head or body that results in rapid movement of the head.\n\nAny concussion signs or symptoms, such as a change in the athlete's behavior, thinking, or physical functioning.\n\nKeep this list of signs and symptoms on hand. Athletes who exhibit or report one or more of the signs and symptoms listed below, or simply say they just "don't feel right" after a bump, blow, or jolt to the head or body, may have a concussion." >
</TextView>
</LinearLayout>
</ScrollView><!--here-->
<android.support.v4.view.ViewPager
android:id="@+id/pager"
android:layout_width="match_parent"
android:layout_height="fill_parent"
android:layout_above="@id/linearLayoutFooter"
android:layout_alignParentTop="true" >
</android.support.v4.view.ViewPager>
</RelativeLayout>
答案 1 :(得分:0)
仅为需要滚动的那些组件提供滚动视图。将其他内容保留在滚动视图之外。您可以使用
等属性将页脚保持在活动的底部 android:alignParentBottom="true"