相关疑难解决方法(0)

RecyclerView - 在特定位置获取视图

我有一个RecyclerView和一个活动ImageView.我正在使用它RecyclerView来水平显示图像列表.当我在点击图片RecyclerViewImageView在活动中应显示图像的大局观.到目前为止一切正常.

现在活动还有两个ImageButtons:imageButton_leftimageButton_right.当我点击时imageButton_left,该图像ImageView应向左转,并且该缩略图RecyclerView应反映此更改.情况类似imageButton_right.

我能够旋转ImageView.但是,我怎么能旋转缩略图RecyclerView?我如何获得ViewHolderImageView

码:

活动XML:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout 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:orientation="vertical">

    <android.support.v7.widget.RecyclerView
        android:id="@+id/recyclerview"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_margin="10dp" />


    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_margin="10dp"
        android:orientation="vertical">

        <ImageView
            android:id="@+id/original_image"
            android:layout_width="200dp"
            android:layout_height="200dp"
            android:scaleType="fitXY"
            android:src="@drawable/image_not_available_2" />

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginTop="10dp"
            android:gravity="center_horizontal"
            android:orientation="horizontal">


            <ImageButton
                android:id="@+id/imageButton_left"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginRight="20dp"
                android:background="@drawable/rotate_left_icon" />

            <ImageButton
                android:id="@+id/imageButton_right"
                android:layout_width="wrap_content" …
Run Code Online (Sandbox Code Playgroud)

java android position widget android-recyclerview

123
推荐指数
9
解决办法
14万
查看次数

RecyclerView - 如何在某个位置平滑滚动到项目顶部?

在RecyclerView上,我可以使用以下命令突然滚动到所选项目的顶部:

((LinearLayoutManager) recyclerView.getLayoutManager()).scrollToPositionWithOffset(position, 0);
Run Code Online (Sandbox Code Playgroud)

但是,这突然将项目移动到顶部位置.我想顺利地移动到项目的顶部.

我也尝试过:

recyclerView.smoothScrollToPosition(position);
Run Code Online (Sandbox Code Playgroud)

但它不能很好地工作,因为它不会将项目移动到选定的顶部位置.它只是滚动列表,直到位置上的项目可见.

android scroll position smooth android-recyclerview

100
推荐指数
7
解决办法
8万
查看次数

如何使用RecyclerView.scrollToPosition()将位置移动到当前视图的顶部?

RecyclerView.scrollToPosition()是非常奇怪的.例如,假设一个RecyclerView名字"rv".

  1. 如果现在项目10在当前RecyclerView,呼叫rv.scrollToPosition(10),RecyclerView则将项目10滚动到底部.

  2. 如果现在项目10在当前RecyclerView,呼叫rv.scrollToPosition(10),将不会有任何滚动,将不会做任何事情.

  3. 如果现在项目10位于当前的顶部,则RecyclerView调用rv.scrollToPosition(10),RecyclerView将项目10滚动到顶部.

为了帮助理解,请看这张照片 在此输入图像描述

但我需要的是,每当我调用它时,RecyclerView就会像案例3一样将所谓的位置滚动到当前视图的顶部.如何做到这一点?

android scroll android-recyclerview

26
推荐指数
4
解决办法
7万
查看次数

Recycleview 滚动到 Nestedscrollview 中不起作用的位置

我在嵌套滚动视图中实现了一个回收视图。但是回收视图滚动到位置方法不起作用。

下面是我的示例代码

  <?xml version="1.0" encoding="utf-8"?>
  <android.support.v4.widget.NestedScrollView 
    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="wrap_content"
    android:paddingBottom="@dimen/activity_vertical_margin"
    app:layout_behavior="@string/appbar_scrolling_view_behavior">

 <LinearLayout
     android:layout_width="match_parent"
     android:layout_height="wrap_content"
     android:orientation="vertical">


  <android.support.v7.widget.RecyclerView
      android:id="@+id/list_view"
      android:layout_width="match_parent"
      android:layout_height="wrap_content"
      app:layout_behavior="@string/appbar_scrolling_view_behavior"/>

 </LinearLayout>

</android.support.v4.widget.NestedScrollView>
Run Code Online (Sandbox Code Playgroud)

下面是滚动的方法

RecyclerView.SmoothScroller smoothScroller = new LinearSmoothScroller(this) {
                @Override
                protected int getVerticalSnapPreference() {
                    return LinearSmoothScroller.SNAP_TO_START;
                }
            };
            smoothScroller.setTargetPosition(pos);
            recyclerView.getLayoutManager().startSmoothScroll(smoothScroller);
Run Code Online (Sandbox Code Playgroud)

android

7
推荐指数
2
解决办法
4497
查看次数

停止用户滚动以在RecyclerView上设置位置

所以我有一个问题,我对Android编程很新,自从我开始编写Android应用程序以来只有6-8周,所以我可能会失明并且看不到简单的答案,但这是我的问题:

我正在制作一个学校项目,我正在尝试开发一个与今天的日历分割视图(下面的那个)相似的日历

图片1

所以我使用GridLayoutManager制作了一个RecyclerView,如下所示:

图2

直到这里一切都很好,但我正在尝试实现在今天的日期设置日历的按钮,事情就是当我滚动时,然后使用scrollToPositionWithOffset(position,0)设置RecyclerView位置; 视图保持从第一次投掷中获得的动量,设置位置然后继续滚动直到动量消失

我搜索了很多寻找解决方案,当我使用gridView而不是RecyclerView时,我使用了smoothScrollToPositionFromTop()来停止滚动,然后使用setSelection()来定位它,但是gridView跳过了框架,我不得不改变,这里使用RecyclerView没有smoothScrollToPositionFromTop和smoothScrollToPosition不会停止滚动,scrollToPosition或scrollToPositionWithOffset也没有.

发现这一点,但没有帮助Scroll RecyclerView在顶部显示所选项目

和其他许多没有帮助的人.

我考虑过实现自己的滚动逻辑,但当我调查它时,我的头部爆炸,我不知道从哪里开始.

有谁知道如何解决这个问题?

android scroll android-recyclerview

6
推荐指数
1
解决办法
1万
查看次数

如何滚动到recyclerview内的偏移量?

如何使用recyclelerview内的偏移滚动到特定位置?

我用过

public LinearLayoutManager linearlayoutmanager;
linearlayoutmanager.scrollToPositionWithOffset(0, scrolled);
Run Code Online (Sandbox Code Playgroud)

我也用过scrollto

mRecyclerView.scrollTo(0, scrolled);
Run Code Online (Sandbox Code Playgroud)

我也使用了smoothScrolltoposition

mRecyclerView.smoothScrollToPosition(scrolled);
Run Code Online (Sandbox Code Playgroud)

但似乎没有人为我工作.

如果有人对此有所了解,请帮助我

UPDATE

功能我在哪里设置我的Recyclerview的适配器

public void Nearby_Search_requestData() {
    OkHttpClient client = new OkHttpClient();
    client = MySSLTrust.trustcert(getActivity());

    RestAdapter adapter = new RestAdapter.Builder().setEndpoint(SEARCH_MERCHANT_ENDPOINT).setClient(new OkClient(client)).build();
    final RetrofitInterface api = adapter.create(RetrofitInterface.class);
    if (api != null) {
        api.post_Nearby_Search(page.toString(), new Callback<Nearby_Search_All>() {
            @Override
            public void success(final Nearby_Search_All server_data, Response response) {
                if (server_data.getSuccess() == 1) {
                    if (server_data.getResults().size() == 0) {
                        if (page != 0) {
                            mRecyclerView.scrollToPosition(firstVis);
                        } else {
                            Log.d("hii", "zero");
            //                NO_MERCHANT.setVisibility(View.VISIBLE); …
Run Code Online (Sandbox Code Playgroud)

android scroll android-recyclerview

4
推荐指数
2
解决办法
1万
查看次数

Kotlin/RecyclerView:scrollToPositionWithOffset 没有出现

我想了解为什么我似乎无法在 LinearLayoutManager 上使用 scrollToPositionWithOffset 方法?请看图片了解我的意思:

未找到 scrollToPositionWithOffset !

一点背景:

图像中的第一行(带有scrollToPosition)是滚动 RecyclerView 以使位置(在本例中为 50)可见- 这通常意味着所选位置显示在可见 RecyclerView 的底部(其中位置 50 在 ' 之后首先变为可见)滚动')。而我想始终将其显示在顶部。从我的研究来看,一些解决方案似乎是使用这种scrollToPositionWithOffset方法(Scroll RecyclerView to show selected item on top

有趣的是,我能够通过自定义 LinearLayoutManager 的 SmoothScroller 来实现我想要的,但是我的数据集很大,所以“平滑滚动”的速度是一个问题,而且我似乎无法在不引起其他问题的情况下提高足够的速度。

简而言之,我希望 scrollToPositionWithOffset 能帮我解决问题。但是,我不知道如何访问该方法。

android kotlin

4
推荐指数
1
解决办法
1578
查看次数

将recyclerview的焦点更改为某些项目的位置?

So I have a standard RecyclerView that takes a list of posts and displays them to the user. My problem is when the user comes into the activity, I want to be able to change the focus to a particular post.

Ex. User A sees that he has a notification that of someone has liked his/her post. He/she clicks that notification, and it loads the activity of user's post, and then the focus changes to the position of the post …

android android-layout android-studio android-recyclerview

-1
推荐指数
1
解决办法
1万
查看次数