我在NestedScrollview中有一个Recyclerview ..一切正常,除了一个thig.我在NestedScrollview中有三个视图,前两个是LinearLayout然后是Recyclerview.当我运行我的应用程序时,活动不显示前两个布局,它从Recyclerview的顶部开始.
它如何显示我的布局:
它的假设如何显示:
我在viewpager下加载这个enite布局,我的viewpager是Coordinator Layout的子代.
<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.NestedScrollView
android:id="@+id/scrollView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/home_layout_background">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal">
<com.daimajia.slider.library.SliderLayout
android:id="@+id/image_slider"
android:layout_width="match_parent"
android:layout_height="@dimen/image_slider_height"
android:layout_marginTop="@dimen/image_slider_top_margin" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/popular_fragment_side_padding"
android:layout_marginRight="@dimen/popular_fragment_side_padding"
android:layout_marginTop="@dimen/popular_fragment_side_padding"
android:orientation="horizontal"
android:weightSum="4">
<RelativeLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1">
<RelativeLayout
android:id="@+id/free_delivery"
android:layout_width="76dp"
android:layout_height="76dp"
android:layout_centerInParent="true"
android:background="@color/white">
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true">
<ImageView
android:id="@+id/btnImageViewFreeDelivery"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:background="@drawable/icon_free_delivery" />
<TextView
android:id="@+id/btnTextFreeDelivery"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/btnImageViewFreeDelivery"
android:layout_centerHorizontal="true"
android:layout_marginTop="2dp"
android:text="@string/free_delivery_txt"
android:textColor="@color/popular_fragment_four_btn_txt"
android:textSize="@dimen/popular_fragment_four_btn_txt_size" />
</RelativeLayout>
</RelativeLayout>
</RelativeLayout>
<RelativeLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1">
<RelativeLayout
android:id="@+id/flash_deals"
android:layout_width="76dp"
android:layout_height="76dp" …Run Code Online (Sandbox Code Playgroud) 我有以下布局结构
--FrameLayout
--scrollview
--LinearLayout
--LinearLayout
--RecyclerView
--LinearLayout
Run Code Online (Sandbox Code Playgroud)
当我到达页面时,它似乎滚动到回收站视图.我只是希望滚动位置在到达页面时位于顶部.
看起来很奇怪,当我在scrollview中的linearlayoout和recyclerview之间切换顺序时,行为是正确的 - 因为滚动位置在顶部
我有一个问题,我的ScrollView片段自动滚动到底部.因此,要解决这个问题,我已新增下列中的RelativeLayout行中建议这个答案:
android:descendantFocusability="blocksDescendants"
但是在添加这一行之后,textIsSelectable就停止了工作.如何添加两行?
这是XML:
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:descendantFocusability="blocksDescendants">
<TextView
android:id="@+id/title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="15dp"
android:textSize="23sp"
android:text="The Beach Beneath the Street"
android:fontFamily="sans-serif-medium"
android:textColor="@color/black"
android:textIsSelectable="true"/>
<TextView
android:id="@+id/content"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/title"
android:padding="15dp"
android:fontFamily="sans-serif-condensed"
android:lineHeight="25dp"
android:lineSpacingMultiplier="1"
android:lineSpacingExtra="6dp"
android:textSize="16sp"
android:text="Never add a RecyclerView or ListView to a scroll view"
android:textIsSelectable="true" />
</RelativeLayout>
Run Code Online (Sandbox Code Playgroud) 我在滚动视图中有一个listview,在此之前几乎有一页滚动,但是一旦我的listview被填充,滚动视图就会移动到列表视图的顶部.我该如何解决这个/防止这种情况发生?
滚动视图XML:
<ScrollView
android:id="@+id/tvscrollview"
android:layout_marginTop="8.0dip"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<LinearLayout
android:id="@+id/linearLayout1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<include
layout="@layout/a" />
<include
layout="@layout/b" />
<include
layout="@layout/c" />
<include
layout="@layout/d" />
<ListView
android:id="@+id/listview"
android:layout_width="fill_parent"
android:layout_height="wrap_content" />
</LinearLayout>
</ScrollView>
Run Code Online (Sandbox Code Playgroud)
我试过做sv.fullScroll(ScrollView.FOCUS_UP); 以及所有那些东西到我的scrollview但它不起作用