【发布时间】:2018-05-07 18:58:17
【问题描述】:
我正在制作一个 xml 布局文件,由 3 部分组成:
第 1 部分:关于某个地点的一些信息和图片。
第 2 部分:两个水平的
Buttons。第 3 部分:
RecyclerView一些人的评论。
这是我的布局文件:
<ScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:name="com.example.abdo.foodproject.OneItemFragment"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.example.abdo.foodproject.OneItemFragment"
tools:layout="@layout/activity_item"
>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/oneitem_background_theme"
android:orientation="vertical"
android:weightSum="13"
>
<LinearLayout>
(...) <!--part 1-->
</LinearLayout>
<LinearLayout <!--part 2-->
android:layout_width="match_parent"
android:layout_height="wrap_content">
<Button
android:id="@+id/review_list"
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="wrap_content"
android:text="@string/reviews"
android:background="@color/colorPrimaryDark"
/>
<Button
android:id="@+id/bestMeal_list"
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="wrap_content"
android:background="@color/colorPrimaryLight"
android:text="@string/best_meal"
/>
</LinearLayout>
<android.support.v7.widget.RecyclerView <!--part 3-->
android:id="@+id/recyclerViewItem"
android:layout_width="match_parent"
android:layout_height="match_parent">
</android.support.v7.widget.RecyclerView>
</LinearLayout>
我想让按钮固定在我的屏幕上,在窗口的顶部,而不会因为滚动而失去它们的视图。
有人知道怎么做吗?
【问题讨论】:
-
显示你的布局文件
-
更新了代码
-
好的,到底是什么不起作用?您的预期结果是什么?
-
我希望当滚动视图工作时,第 1 部分消失,这两个按钮只是粘在我的窗口顶部,不会向上移动并消失。
-
您希望它们在哪里保持静态?在底部还是顶部?
标签: android xml scrollview