我有一个滚动浏览的滚动视图,直到我在里面添加元素并停止滚动。我尝试了很多东西,包括将高度更改为fill_parent或wrap_content,但不知怎的,我找不到阻止滚动的值。有人可以帮忙吗?这是我的布局:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout 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:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/bg_layout"
android:fitsSystemWindows="false"
android:background="@drawable/detail_background"
tools:context="com.kalianey.oxapp.views.fragments.ProfileFragment">
<com.kalianey.oxapp.utils.UIParallaxScroll //extends ScrollView
android:id="@+id/scroller"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true"
app:headerView="@+id/layout_top">
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:weightSum="1"
android:orientation="vertical">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="fill_parent"
android:layout_weight="0.4"
android:id="@+id/cover_container">
<com.kalianey.oxapp.utils.UICircularImage
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/image_view"
android:layout_width="125dp"
android:layout_height="125dp"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_marginTop="50dp"
android:layout_marginBottom="5dp"
app:line_color="@android:color/white"
app:line_color_press="@color/theme_color"
app:line_width="1dp"
app:padding="0dp" />
<TextView
android:id="@+id/title"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:fontFamily="sans-serif-light"
android:gravity="center"
android:paddingLeft="16dp"
android:paddingTop="10dp"
android:paddingRight="16dp"
android:text="@string/detail_title_placeholder"
android:textSize="@dimen/textsize_xlarge"
android:layout_below="@+id/image_view"
android:textColor="@android:color/white"/>
<TextView
android:id="@+id/sumary"
android:layout_below="@+id/title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:fontFamily="sans-serif-light"
android:gravity="center"
android:paddingBottom="16dp"
android:text="@string/sumary_placeholder"
android:textColor="@color/white_transparent"
android:textSize="@dimen/textsize_medium_small" />
<LinearLayout
android:id="@+id/statistics"
android:layout_below="@+id/sumary"
android:background="@color/gray_transparent"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:padding="5dp"
android:orientation="vertical"
android:background="@drawable/border_right" >
<ImageButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/imageButtonFriend"
android:layout_gravity="center_horizontal"
android:src="@drawable/user"
android:background="@android:color/transparent"/>
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="5dp"
android:layout_weight="1"
android:background="@color/gray_transparent"
android:orientation="vertical" >
<ImageButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/imageButtonFavorite"
android:layout_gravity="center_horizontal"
android:src="@drawable/star"
android:background="@android:color/transparent"/>
</LinearLayout>
</LinearLayout>
</RelativeLayout>
<LinearLayout
android:id="@+id/informations_container"
android:layout_width="match_parent"
android:layout_height="fill_parent"
android:layout_weight="0.6"
android:orientation="vertical"
android:background="@android:color/white"
android:layout_below="@+id/cover_container"
android:gravity="center"
android:padding="10dp">
<com.kalianey.oxapp.utils.UITabs
android:id="@+id/toggle"
android:layout_gravity="center"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_below="@+id/informations_container">
<RadioButton
android:id="@+id/toggle1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:padding="5dp"
android:checked="true"
android:text="@string/description_tab_1"
style="@style/UITabs" />
<RadioButton
android:id="@+id/toggle2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:padding="5dp"
android:text="@string/description_tab_2"
android:layout_gravity="bottom"
style="@style/UITabs" />
</com.kalianey.oxapp.utils.UITabs>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/profile_photo_text"
android:text="@string/profile_photo_text"
android:layout_gravity="left"
android:layout_marginBottom="10dp"
android:layout_marginLeft="@dimen/activity_horizontal_margin"
android:layout_marginRight="@dimen/activity_horizontal_margin"
android:layout_marginTop="20dp" />
<TextView
android:id="@+id/noPhotos"
android:layout_below="@+id/profile_photo_text"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:fontFamily="sans-serif-light"
android:gravity="center"
android:text="@string/noPhotos"
android:textColor="@color/gray_light"
android:textSize="@dimen/textsize_medium_small"
android:textStyle="italic"
android:height="70dp"
android:visibility="gone"/>
<android.support.v7.widget.RecyclerView
android:id="@+id/grid_view"
android:layout_width="match_parent"
android:layout_height="250dp"
app:layoutManager="StaggeredGridLayoutManager"
android:layout_marginLeft="@dimen/activity_horizontal_margin"
android:layout_marginRight="@dimen/activity_horizontal_margin"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/profile_friend_text"
android:text="@string/profile_friend_text"
android:layout_gravity="left"
android:layout_marginTop="20dp"
android:layout_marginLeft="@dimen/activity_horizontal_margin"
android:layout_marginRight="@dimen/activity_horizontal_margin"/>
<TextView
android:id="@+id/noFriends"
android:layout_below="@+id/profile_friend_text"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:fontFamily="sans-serif-light"
android:gravity="center"
android:text="@string/noFriends"
android:textColor="@color/gray_light"
android:textSize="@dimen/textsize_medium_small"
android:textStyle="italic"
android:minHeight="50dp"
android:visibility="gone"/>
<org.lucasr.twowayview.TwoWayView
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/friends_list"
style="@style/TwoWayView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:drawSelectorOnTop="false"
tools:context=".MainActivity"
android:paddingTop="10dp"
android:paddingBottom="10dp"
android:layout_marginLeft="@dimen/activity_horizontal_margin"
android:layout_marginRight="@dimen/activity_horizontal_margin"/>
<se.emilsjolander.stickylistheaders.StickyListHeadersListView
android:id="@+id/questions_list"
android:layout_width="match_parent"
android:layout_height="500dp"
android:visibility="gone" />
</LinearLayout>
</LinearLayout>
</com.kalianey.oxapp.utils.UIParallaxScroll>
<!-- "ActionBar" -->
</RelativeLayout>
答案 0 :(得分:0)
看看下面的xml代码,它将帮助您构建具有滚动的屏幕,即使它包含回收站视图。
function is_pentagonal($c) {
$x = (1+sqrt(1+24*$c))/(6);
return $x == (int)$x;
}
您可以在此使用您想要的元素。您也可以将CoordinatorLayout基础更改为LinearLayout或RelativeLayout。另外,不要忘记在build.gradle文件中添加以下支持依赖项部分。
<android.support.design.widget.CoordinatorLayout
android:id="@+id/container"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.v4.widget.NestedScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:paddingTop="24dp">
<android.support.v7.widget.CardView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="16dp"
android:layout_marginLeft="16dp"
android:layout_marginRight="16dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="25dp"
android:gravity="center_horizontal"
android:textStyle="bold"
android:text=" " />
<android.support.v7.widget.RecyclerView
android:id="@+id/rcy1"
android:layout_width="match_parent"
android:layout_height="250dp"
android:numColumns="4"
android:scrollbars="vertical"
android:adjustViewBounds="true"
android:gravity="center_horizontal"
android:horizontalSpacing="1dp"
android:padding="1dp"
android:background="@color/white"
android:stretchMode="columnWidth"
android:verticalSpacing="1dp"/>
</LinearLayout>
</android.support.v7.widget.CardView>
<android.support.v7.widget.CardView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="16dp"
android:layout_marginLeft="16dp"
android:layout_marginRight="16dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<android.support.v7.widget.RecyclerView
android:id="@+id/rcy2"
android:layout_width="match_parent"
android:layout_height="300dp"
android:layout_marginTop="10dp"
android:numColumns="3"
android:scrollbars="vertical"
android:adjustViewBounds="true"
android:gravity="center_horizontal"
android:horizontalSpacing="1dp"
android:padding="1dp"
android:background="@color/white"
android:stretchMode="columnWidth"
android:verticalSpacing="1dp"/>
</LinearLayout>
</android.support.v7.widget.CardView>
</LinearLayout>
</android.support.v4.widget.NestedScrollView>
</android.support.design.widget.CoordinatorLayout>