gpt4 book ai didi

android - 滚动到完整 View ,其中包含回收器 View

转载 作者:塔克拉玛干 更新时间:2023-11-02 19:51:37 25 4
gpt4 key购买 nike

我想实现一个屏幕,其中我在顶部和下方有一个布局,我有一个回收站 View ,如下所示:

<RelativeLayout
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"
xmlns:fab="http://schemas.android.com/apk/res-auto"
tools:context="com.app.InstHomeDir.Fragments.PendingDocument"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/main_bg"
>

<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginLeft="15dp"
android:layout_marginRight="15dp"
android:layout_marginBottom="15dp"
>

<android.support.v7.widget.CardView

android:background="@color/white"
app:cardElevation="2dp"
app:cardCornerRadius="2dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
>
<LinearLayout
android:orientation="vertical"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<com.app.InstHomeDir.Util.Roboto_Edit_Text_Bold
android:textColor="@color/bl2d2d2d"
android:padding="5dp"
android:text="DOCUMENT LIST"
android:textSize="20sp"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<com.app.InstHomeDir.Util.Roboto_EditText
android:padding="5dp"
android:textColor="#6f6f6f"
android:layout_marginTop="5dp"
android:layout_width="wrap_content"
android:textSize="12sp"
android:text="@string/Pending_Doc"
android:layout_height="wrap_content"/>
</LinearLayout>


</android.support.v7.widget.CardView>


<android.support.v7.widget.RecyclerView
android:id="@+id/recycler_penddoc"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_anchor="@id/toolbar_layout"
app:layout_anchorGravity="bottom|center"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
>

</android.support.v7.widget.RecyclerView>


</LinearLayout>



</RelativeLayout>

现在我想为整个 View 提供 ScrollView ,但是当我这样做时,屏幕的滚动不流畅,因为屏幕上有两个滚动条,我该如何解决这个问题?谁能帮帮我?

最佳答案

添加页眉和页脚是一种方法,但我发现了一种更容易实现的 View 。将整个 View 放在 ScrollView 中。现在这会使滚动有点慢,而且看起来不太好,所以要克服这个问题,请使用以下代码:

  layoutManager = new LinearLayoutManager(getActivity()){
@Override
public boolean canScrollVertically() {
return false;
}
};

现在的问题是,当我将整个 View 添加到 ScrollView 中时,同一 View 中有 2 个滚动条。所以我们面临这个问题。现在,如果我们删除其中一个的滚动属性,它就会再次顺利运行。所以我们删除了回收器 View 的滚动属性,因为它是 subview 。

像魅力一样工作。

关于android - 滚动到完整 View ,其中包含回收器 View ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35983226/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com