小编Has*_*ikh的帖子

滚动时,RecyclerView中的多个倒计时器会闪烁

我已经为每个RecyclerView项目实现了倒计时器,这是一个片段活动.倒计时器显示到期时间.倒计时器工作正常,但向上滚动时会开始闪烁.搜索了很多,但没有得到很好的参考.谁能帮我?

这是我的RecyclerView适配器

public class MyOfferAdapter extends RecyclerView.Adapter<MyOfferAdapter.FeedViewHolder>{
private final Context mContext;
private final LayoutInflater mLayoutInflater;
private ArrayList<Transactions> mItems = new ArrayList<>();
private ImageLoader mImageLoader;
private String imageURL;
private View mView;
private String mUserEmail;

public MyOfferAdapter(Context context) {
    mContext = context;
    mLayoutInflater = LayoutInflater.from(context);
    VolleySingleton mVolley = VolleySingleton.getInstance(mContext);
    mImageLoader = mVolley.getImageLoader();
}


public void addItems(ArrayList<Transactions> items,String userEmail) {
    int count = mItems.size();
    mItems.addAll(items);
    mUserEmail = userEmail;
    notifyItemRangeChanged(count, items.size());
}


@Override
public FeedViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
    mView = mLayoutInflater.inflate(R.layout.my_feed_item_layout, parent, …
Run Code Online (Sandbox Code Playgroud)

android countdowntimer android-recyclerview

12
推荐指数
2
解决办法
7460
查看次数

向上滚动时折叠工具栏中的 SearchView 被隐藏

我在 MainActivity 中有一个折叠工具栏,工具栏中有一个 SearchView。单击搜索视图图标时,搜索视图将折叠在工具栏中。当工具栏折叠时它工作正常。但是,如果我单击搜索图标并向上滚动,则折叠的搜索视图将隐藏。我想让折叠的搜索视图在向上滚动时可见。我正在关注此链接MaterialSearchView

这是折叠工具栏折叠时的屏幕 在此处输入图片说明

现在,如果我点击搜索图标,屏幕看起来像这样 在此处输入图片说明

到目前为止,搜索视图工作正常。现在如果我向上滚动屏幕看起来像这样 在此处输入图片说明

现在,如果我单击搜索图标,则搜索视图会折叠但被隐藏。因此,即使折叠工具栏未折叠,我也希望搜索视图在工具栏中折叠。这是当工具栏未折叠并单击搜索图标时我想要的屏幕截图

在此处输入图片说明

这是我的activity_main.xml

<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/main_content"
android:layout_width="match_parent"
android:layout_height="match_parent">

<android.support.design.widget.AppBarLayout
    android:id="@+id/appbar"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar">

    <android.support.design.widget.CollapsingToolbarLayout
        android:id="@+id/collapsing_toolbar"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:fitsSystemWindows="true"
        app:contentScrim="?attr/colorPrimary"
        app:expandedTitleMarginEnd="64dp"
        app:expandedTitleMarginStart="48dp"
        app:expandedTitleTextAppearance="@android:color/transparent"
        app:layout_scrollFlags="scroll|exitUntilCollapsed">

        <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:orientation="vertical">

            <com.daimajia.slider.library.SliderLayout
                android:id="@+id/slider"
                android:layout_width="match_parent"
                android:layout_height="150dp"
                />

        </RelativeLayout>
        <android.support.v7.widget.Toolbar
            android:id="@+id/toolbar"
            android:layout_width="match_parent"
            android:layout_height="?attr/actionBarSize"
            app:popupTheme="@style/ThemeOverlay.AppCompat.Light"
            app:layout_collapseMode="pin" />
        <com.miguelcatalan.materialsearchview.MaterialSearchView
            android:id="@+id/search_view"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            />
    </android.support.design.widget.CollapsingToolbarLayout>
    <android.support.design.widget.TabLayout
        android:id="@+id/tabs"
        app:tabIndicatorColor="@color/pink"
        android:layout_width="match_parent"
        android:layout_height="wrap_content" />

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



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

<android.support.design.widget.FloatingActionButton
    android:id="@+id/fab_list"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:clickable="true"
    android:layout_margin="16dp"
    android:src="@drawable/ic_launcher_white"
    android:layout_gravity="end|bottom"
    app:rippleColor="@android:color/white"
    app:backgroundTint="@color/primary"
    app:elevation="10dp"
    /> …
Run Code Online (Sandbox Code Playgroud)

android android-layout searchview android-coordinatorlayout android-collapsingtoolbarlayout

5
推荐指数
1
解决办法
2693
查看次数