gpt4 book ai didi

android - 在折叠操作栏搜索 recyclerview 移动到屏幕底部

转载 作者:行者123 更新时间:2023-11-30 01:57:18 25 4
gpt4 key购买 nike

所以问题是,

当 Actionbar searchitem 展开时,recyclerview 看起来是正确的,但是当我单击 searchitem 上的后退按钮时,它会折叠并且 recyclerview 会自动移动到屏幕底部,如下图所示

屏幕 1:当我点击操作栏的搜索项时

enter image description here

屏幕 2:当我点击搜索项的后退按钮时

enter image description here

屏幕 3:当我尝试滚动 recyclerview 时,它会自动移动到底部

enter image description here

我正在使用以下库

compile 'com.android.support:appcompat-v7:22.2.0'  

compile 'com.android.support:design:22.2.0'

compile 'com.android.support:recyclerview-v7:22.2.0'

我正在使用以下 fragment 布局 clinic_fragment.xml

<android.support.v7.widget.RecyclerView
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/my_recycler_view"

android:scrollbars="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#ffffff"
>
</android.support.v7.widget.RecyclerView>

我的 fragment 类的onCreateView()方法

  @Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
Bundle arguments = getArguments();
int pageNumber = arguments.getInt(ARG_PAGE);
RecyclerView recyclerView = (RecyclerView) inflater.inflate(R.layout.fragment_clinic,container,false);
recyclerView.setAdapter(new YourRecyclerAdapter(getActivity()));
recyclerView.setLayoutManager(/*new LinearLayoutManager(getActivity())*/new GridLayoutManager(getActivity(),4, LinearLayoutManager.VERTICAL,false));
return recyclerView;
}

我的 Activity 布局:

<android.support.design.widget.CoordinatorLayout
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:id="@+id/root_coordinator"
android:layout_width="match_parent"
android:layout_height="match_parent">

<android.support.design.widget.AppBarLayout
android:id="@+id/app_bar_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content">

<android.support.v7.widget.Toolbar
android:id="@+id/app_bar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
app:layout_scrollFlags="scroll|enterAlways"
/>

<android.support.design.widget.TabLayout
android:id="@+id/tab_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/colorAccent"
app:tabIndicatorColor="@color/colorPrimary"
app:tabSelectedTextColor="@android:color/white"
app:tabTextColor="#EEE" />

</android.support.design.widget.AppBarLayout>

<android.support.v4.view.ViewPager
android:id="@+id/view_pager"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior" />

</android.support.design.widget.CoordinatorLayout>

请注意:

这个问题可以通过从 RecyclerView 中删除 android:scrollbars="vertical" 来解决,但我想在滚动时显示滚动条,因此我无法删除它。

请帮忙,谢谢

最佳答案

这是一个应该修复的已知错误。尝试升级到:

compile 'com.android.support:design:22.2.1'  
compile 'com.android.support:appcompat-v7:22.2.1'
compile 'com.android.support:recyclerview-v7:22.2.1'

关于android - 在折叠操作栏搜索 recyclerview 移动到屏幕底部,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32027195/

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