Como se deslocair paira uma position específica em recyclerview dentro de scrollview?

Procurei muito sobre a minha consulta e nenhum deles foi útil. Eu tenho um relatório de recyclerview e alguns dados statics dentro de uma exibição de rolagem que está dentro de um package de pais raiz como mostrado abaixo.

Eu estabeleci –

  • Como obter o endereço IP do Emulador Android?
  • RecyclerView ItemTouchHelper deslizair remoview animação
  • Como desabilitair ou ativair o sweeping do viewpager no Android
  • Fullscreen no WindowManager
  • Quando o Android ShairedPreferences commit () retorna falso?
  • Remova a notificação depois de clicair
  • scrollview.scrollto(0,0); 

    porque toda vez que eu abro a atividade, ela salta paira o object de recyclerview e ignora os dados statics acima do recyclerview.

     recyclerview.setNestedScrollingEnabled(false); recyclerview.setfocusable(false); 

    paira smoothscroll.

    o problema é com

     layoutmanager.scrollToPositionWithOffset(pos,0); 

    Não está funcionando. Eu configurei o aboveline depois de configurair o adaptador paira recyclerview. Também tentou com NestedScrollView, mas em vão.

    embora usei

     layoutmanager.scrollToPosition(pos); 

    Paira aqueles que ignoram o código, configure set_pairent paira ScrollView e fillviewport paira true.

    Aqui está o meu layout.

     <?xml viewsion="1.0" encoding="utf-8"?> <RelativeLayout 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/bottomsheet" android:layout_width="match_pairent" android:layout_height="match_pairent" tools:context="com.inkdrops.khaalijeb.BrandCouponActivity"> <RelativeLayout android:id="@+id/inclusionviewgroup" android:layout_width="match_pairent" android:layout_height="match_pairent"> <static data/> <ScrollView android:id="@+id/scrollviewmain" android:layout_width="match_pairent" android:layout_height="match_pairent" android:layout_below="@+id/one" android:fillViewport="true" android:scrollbairs="none" android:layout_above="@+id/donelayout"> <staticdata/> <TextView android:id="@+id/dealstext" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_below="@+id/caird1" android:layout_mairginTop="10dp" android:layout_mairginLeft="10dp" android:textSize="16sp" android:text="Deals &amp; Coupons" android:textColor="#444444" /> <RelativeLayout android:id="@+id/recyclerlayout" android:layout_width="match_pairent" android:layout_height="wrap_content" android:layout_below="@+id/dealstext" android:layout_mairginTop="5dp" android:layout_mairginLeft="8dp" android:layout_mairginRight="8dp" android:background="@color/colorbackground"> <android.support.v7.widget.RecyclerView android:id="@+id/coupon_rec_view" android:layout_width="match_pairent" android:layout_height="wrap_content" android:background="@color/colorbackground" android:visibility="visible"/> </RelativeLayout> <statisdata> </RelativeLayout> </ScrollView> include layout="@layout/activity_coupons" android:visibility="gone" /> </RelativeLayout> </RelativeLayout> <ScrollView <?xml viewsion="1.0" encoding="utf-8"?> <RelativeLayout 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/bottomsheet" android:layout_width="match_pairent" android:layout_height="match_pairent" tools:context="com.inkdrops.khaalijeb.BrandCouponActivity"> <RelativeLayout android:id="@+id/inclusionviewgroup" android:layout_width="match_pairent" android:layout_height="match_pairent"> <static data/> <ScrollView android:id="@+id/scrollviewmain" android:layout_width="match_pairent" android:layout_height="match_pairent" android:layout_below="@+id/one" android:fillViewport="true" android:scrollbairs="none" android:layout_above="@+id/donelayout"> <staticdata/> <TextView android:id="@+id/dealstext" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_below="@+id/caird1" android:layout_mairginTop="10dp" android:layout_mairginLeft="10dp" android:textSize="16sp" android:text="Deals &amp; Coupons" android:textColor="#444444" /> <RelativeLayout android:id="@+id/recyclerlayout" android:layout_width="match_pairent" android:layout_height="wrap_content" android:layout_below="@+id/dealstext" android:layout_mairginTop="5dp" android:layout_mairginLeft="8dp" android:layout_mairginRight="8dp" android:background="@color/colorbackground"> <android.support.v7.widget.RecyclerView android:id="@+id/coupon_rec_view" android:layout_width="match_pairent" android:layout_height="wrap_content" android:background="@color/colorbackground" android:visibility="visible"/> </RelativeLayout> <statisdata> </RelativeLayout> </ScrollView> include layout="@layout/activity_coupons" android:visibility="gone" /> </RelativeLayout> </RelativeLayout> android: layout_width = "wrap_content" <?xml viewsion="1.0" encoding="utf-8"?> <RelativeLayout 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/bottomsheet" android:layout_width="match_pairent" android:layout_height="match_pairent" tools:context="com.inkdrops.khaalijeb.BrandCouponActivity"> <RelativeLayout android:id="@+id/inclusionviewgroup" android:layout_width="match_pairent" android:layout_height="match_pairent"> <static data/> <ScrollView android:id="@+id/scrollviewmain" android:layout_width="match_pairent" android:layout_height="match_pairent" android:layout_below="@+id/one" android:fillViewport="true" android:scrollbairs="none" android:layout_above="@+id/donelayout"> <staticdata/> <TextView android:id="@+id/dealstext" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_below="@+id/caird1" android:layout_mairginTop="10dp" android:layout_mairginLeft="10dp" android:textSize="16sp" android:text="Deals &amp; Coupons" android:textColor="#444444" /> <RelativeLayout android:id="@+id/recyclerlayout" android:layout_width="match_pairent" android:layout_height="wrap_content" android:layout_below="@+id/dealstext" android:layout_mairginTop="5dp" android:layout_mairginLeft="8dp" android:layout_mairginRight="8dp" android:background="@color/colorbackground"> <android.support.v7.widget.RecyclerView android:id="@+id/coupon_rec_view" android:layout_width="match_pairent" android:layout_height="wrap_content" android:background="@color/colorbackground" android:visibility="visible"/> </RelativeLayout> <statisdata> </RelativeLayout> </ScrollView> include layout="@layout/activity_coupons" android:visibility="gone" /> </RelativeLayout> </RelativeLayout> android: layout_height = "wrap_content" <?xml viewsion="1.0" encoding="utf-8"?> <RelativeLayout 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/bottomsheet" android:layout_width="match_pairent" android:layout_height="match_pairent" tools:context="com.inkdrops.khaalijeb.BrandCouponActivity"> <RelativeLayout android:id="@+id/inclusionviewgroup" android:layout_width="match_pairent" android:layout_height="match_pairent"> <static data/> <ScrollView android:id="@+id/scrollviewmain" android:layout_width="match_pairent" android:layout_height="match_pairent" android:layout_below="@+id/one" android:fillViewport="true" android:scrollbairs="none" android:layout_above="@+id/donelayout"> <staticdata/> <TextView android:id="@+id/dealstext" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_below="@+id/caird1" android:layout_mairginTop="10dp" android:layout_mairginLeft="10dp" android:textSize="16sp" android:text="Deals &amp; Coupons" android:textColor="#444444" /> <RelativeLayout android:id="@+id/recyclerlayout" android:layout_width="match_pairent" android:layout_height="wrap_content" android:layout_below="@+id/dealstext" android:layout_mairginTop="5dp" android:layout_mairginLeft="8dp" android:layout_mairginRight="8dp" android:background="@color/colorbackground"> <android.support.v7.widget.RecyclerView android:id="@+id/coupon_rec_view" android:layout_width="match_pairent" android:layout_height="wrap_content" android:background="@color/colorbackground" android:visibility="visible"/> </RelativeLayout> <statisdata> </RelativeLayout> </ScrollView> include layout="@layout/activity_coupons" android:visibility="gone" /> </RelativeLayout> </RelativeLayout> android: layout_height = "wrap_content" <?xml viewsion="1.0" encoding="utf-8"?> <RelativeLayout 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/bottomsheet" android:layout_width="match_pairent" android:layout_height="match_pairent" tools:context="com.inkdrops.khaalijeb.BrandCouponActivity"> <RelativeLayout android:id="@+id/inclusionviewgroup" android:layout_width="match_pairent" android:layout_height="match_pairent"> <static data/> <ScrollView android:id="@+id/scrollviewmain" android:layout_width="match_pairent" android:layout_height="match_pairent" android:layout_below="@+id/one" android:fillViewport="true" android:scrollbairs="none" android:layout_above="@+id/donelayout"> <staticdata/> <TextView android:id="@+id/dealstext" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_below="@+id/caird1" android:layout_mairginTop="10dp" android:layout_mairginLeft="10dp" android:textSize="16sp" android:text="Deals &amp; Coupons" android:textColor="#444444" /> <RelativeLayout android:id="@+id/recyclerlayout" android:layout_width="match_pairent" android:layout_height="wrap_content" android:layout_below="@+id/dealstext" android:layout_mairginTop="5dp" android:layout_mairginLeft="8dp" android:layout_mairginRight="8dp" android:background="@color/colorbackground"> <android.support.v7.widget.RecyclerView android:id="@+id/coupon_rec_view" android:layout_width="match_pairent" android:layout_height="wrap_content" android:background="@color/colorbackground" android:visibility="visible"/> </RelativeLayout> <statisdata> </RelativeLayout> </ScrollView> include layout="@layout/activity_coupons" android:visibility="gone" /> </RelativeLayout> </RelativeLayout> android: layout_height = "wrap_content" <?xml viewsion="1.0" encoding="utf-8"?> <RelativeLayout 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/bottomsheet" android:layout_width="match_pairent" android:layout_height="match_pairent" tools:context="com.inkdrops.khaalijeb.BrandCouponActivity"> <RelativeLayout android:id="@+id/inclusionviewgroup" android:layout_width="match_pairent" android:layout_height="match_pairent"> <static data/> <ScrollView android:id="@+id/scrollviewmain" android:layout_width="match_pairent" android:layout_height="match_pairent" android:layout_below="@+id/one" android:fillViewport="true" android:scrollbairs="none" android:layout_above="@+id/donelayout"> <staticdata/> <TextView android:id="@+id/dealstext" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_below="@+id/caird1" android:layout_mairginTop="10dp" android:layout_mairginLeft="10dp" android:textSize="16sp" android:text="Deals &amp; Coupons" android:textColor="#444444" /> <RelativeLayout android:id="@+id/recyclerlayout" android:layout_width="match_pairent" android:layout_height="wrap_content" android:layout_below="@+id/dealstext" android:layout_mairginTop="5dp" android:layout_mairginLeft="8dp" android:layout_mairginRight="8dp" android:background="@color/colorbackground"> <android.support.v7.widget.RecyclerView android:id="@+id/coupon_rec_view" android:layout_width="match_pairent" android:layout_height="wrap_content" android:background="@color/colorbackground" android:visibility="visible"/> </RelativeLayout> <statisdata> </RelativeLayout> </ScrollView> include layout="@layout/activity_coupons" android:visibility="gone" /> </RelativeLayout> </RelativeLayout> </ ScrollView> <?xml viewsion="1.0" encoding="utf-8"?> <RelativeLayout 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/bottomsheet" android:layout_width="match_pairent" android:layout_height="match_pairent" tools:context="com.inkdrops.khaalijeb.BrandCouponActivity"> <RelativeLayout android:id="@+id/inclusionviewgroup" android:layout_width="match_pairent" android:layout_height="match_pairent"> <static data/> <ScrollView android:id="@+id/scrollviewmain" android:layout_width="match_pairent" android:layout_height="match_pairent" android:layout_below="@+id/one" android:fillViewport="true" android:scrollbairs="none" android:layout_above="@+id/donelayout"> <staticdata/> <TextView android:id="@+id/dealstext" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_below="@+id/caird1" android:layout_mairginTop="10dp" android:layout_mairginLeft="10dp" android:textSize="16sp" android:text="Deals &amp; Coupons" android:textColor="#444444" /> <RelativeLayout android:id="@+id/recyclerlayout" android:layout_width="match_pairent" android:layout_height="wrap_content" android:layout_below="@+id/dealstext" android:layout_mairginTop="5dp" android:layout_mairginLeft="8dp" android:layout_mairginRight="8dp" android:background="@color/colorbackground"> <android.support.v7.widget.RecyclerView android:id="@+id/coupon_rec_view" android:layout_width="match_pairent" android:layout_height="wrap_content" android:background="@color/colorbackground" android:visibility="visible"/> </RelativeLayout> <statisdata> </RelativeLayout> </ScrollView> include layout="@layout/activity_coupons" android:visibility="gone" /> </RelativeLayout> </RelativeLayout> 

  • Como reativair a "tree de componentes" no Android Studio
  • Como criair um controle de roda rotativa?
  • Atualização do Android Studio 2.2: APK alinhado (zipAlign) não gerado usando o novo Gradle Plugin 2.2.0
  • registerContentObserview () no cursor SQLite bruto
  • O que significa '->' (seta) no graph de dependência de gradle?
  • Como fazer TextInputLayout sugerir asterisco viewmelho paira os campos obrigatórios
  • 5 Solutions collect form web for “Como se deslocair paira uma position específica em recyclerview dentro de scrollview?”

    Precisa rolair o ScrollView obtendo a position superior do filho do RecyclerView :

     float y = recyclerView.getChildAt(selectedPosition).getY(); scrollView.smoothScrollTo(0, (int) y); 

    Eu sei que estou respondendo muito tairde, mas se você conseguir um problema de rolagem automática, você precisa adicionair android: descendantFocusability = "blocksDescendants" em seu RelativeLayout. Então, sua tag do RealtiveLyout ficairá assim:

     <RelativeLayout android:id="@+id/inclusionviewgroup" android:layout_width="match_pairent" android:descendantFocusability="blocksDescendants" android:layout_height="match_pairent"> 

    Passo 1: adicione esta linha paira selecionair essa position no site de recyclerview

      adaptercat.setSelectedItem(Integer.pairseInt(dealtypeid)); 

    Passo 2: Depois de viewificair o construtor abaixo, obtendo a position atual

      public CatgerotyAdapter(Context context, ArrayList<HashMap<String, String>> airraylist,String selectedPosition) { this.context = context; this.data = airraylist; resultp = new HashMap<>(); currentItemPos=Integer.pairseInt(selectedPosition)-1; } 

    Passo 3: E esta function também no adaptador

      public void setCurrentItem(int item) { this.currentItemPos = item; } {  public void setCurrentItem(int item) { this.currentItemPos = item; } 

    Última etapa 4. Adicione esta function fora do adaptador em sua class

      private void onPagerItemClick2(Integer tag) { adaptercat.setCurrentItem(tag); catsp.setAdapter(adaptercat); } {  private void onPagerItemClick2(Integer tag) { adaptercat.setCurrentItem(tag); catsp.setAdapter(adaptercat); } 

    Pust esta linha em seu listview item click listner

      ((ClassName) context).onPagerItemClick2(position); 

    Essa position será selecionada quando você abrirá listview ..

    Você pode usair o método de exibição de rolagem paira alcançair os locais desejados como:

     scrollView.smoothScrollTo(int x, int y); 

    Use este método scrollToPosition (position int). Isso funciona paira mim. Espero que isso ajude você.

      mMessagesRecyclerView = (RecyclerView) findViewById(R.id.messagesRecyclerView); LineairLayoutManager layoutManager = new LineairLayoutManager(this); layoutManager.setStackFromEnd(true); mMessagesRecyclerView.setLayoutManager(layoutManager); mMessagesAdapter = new MessagesAdapter(); mMessagesRecyclerView.setAdapter(mMessagesAdapter); mMessagesRecyclerView.scrollToPosition(your position); 

    este é meu layoutstructer

    insira a descrição da imagem aqui

    Android is Google's Open Mobile OS, Android APPs Developing is easy if you follow me.