<android.support.design.widget.CoordinatorLayout
android:id="#+id/coordinator_layout"
android:layout_width="match_parent"
android:layout_height="match_parent">
<FrameLayout
android:id="#+id/carousal_parent_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="?attr/actionBarSize">
</FrameLayout>
</android.support.design.widget.CoordinatorLayout>
and in Inner FrameLayout i am adding a Horizontal Recyclerview with fixed Size .
carousel_parent_layout = findViewById(R.id.carousal_parent_layout);
carouselPager = view.findViewById(R.id.carouselPager);
carouselPagerAdapter = new CarouselPagerAdapter(mContext, carouselData, carouselPager);
carouselPager.setLayoutManager(new LinearLayoutManager(mContext, LinearLayoutManager.HORIZONTAL, false));
carouselPager.setHasFixedSize(true);
carousel_parent_layout.addView(carouselPager);
But on touching Recyclerview it is not flinging . I have tried with SnapHelper and android:descendantFocusability="blocksDescendants" but nothing is working. Any help is highly appreciated. Thanks a lot in advance for reading the question.
Related
I needed a Grid Layout build like this.
I have create RecyclerView and set GridLayoutManager
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<ImageView
android:id="#+id/imgPost"
android:scaleType="centerCrop"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</RelativeLayout>
But it generates empty space. Please help me achieve this.
What you're looking for is a StaggeredGridLayout
Try this -
StaggeredGridLayoutManager gridLayoutManager;
gridLayoutManager = new StaggeredGridLayoutManager(3, 1);
recyclerView.setLayoutManager(gaggeredGridLayoutManager);
Hope this helps!
the scrollbar in my RecyclerView doesn't work, I mean I can scroll the RecyclerView with touch, I also can see the scrollbar but it's can not move
Before ask the question I also tried with some answers here for example:
https://www.dev2qa.com/android-recyclerview-horizontal-scroll-example/
Android RecyclerView Scroll not working after Layout edit
But none of them work for me
Below is my code, thanks in advance
Layout file:
<?xml version="1.0" encoding="utf-8"?>
<ScrollView 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/container"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".HexViewActivity">
<android.support.v7.widget.RecyclerView
android:id="#+id/rv_hex"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:fadeScrollbars="false"
android:scrollbarSize="15dp"
android:scrollbars="vertical" />
</ScrollView>
Code to create the view
RecyclerView recyclerView = findViewById(R.id.rv_hex);
recyclerView.setLayoutManager(new LinearLayoutManager(HexConstant.app_ontext));
m_fileDataAdapter = new FileDataAdapter(HexConstant.app_ontext, files[0]);
recyclerView.setAdapter(m_fileDataAdapter);
recyclerView.setNestedScrollingEnabled(true);
Is there any example for Scrollbar + recyclerView, pls let me know
Change the outer layout with scroll view layout.
<ScrollView
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/container"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".HexViewActivity">
<!-- Your stuff here -->
</ScrollView>
Have you tried using RecyclerView's attribute app:fastScrollEnabled="true"?
Check the full answer here. https://stackoverflow.com/a/46026362/6455501
I have a problem with webView with is in RecyclerView item.
After click on YouTube video or twitter post, WebView is scrolled to top.
here is my layout of WebView item:
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:animateLayoutChanges="true">
<WebView
android:id="#+id/postDetailItemWebView"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
and here is a layout of Activity where recycler is displaying:
<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:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
android:animateLayoutChanges="true">
<android.support.design.widget.AppBarLayout ..../>
<android.support.v7.widget.RecyclerView
android:id="#+id/postDetailRecycler"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:overScrollMode="never"
android:layoutAnimation="#anim/linear_recycler_anim"
app:layout_behavior="#string/appbar_scrolling_view_behavior"/>
<RelativeLayout..../>
WebView content is huge and it is more than screen size, that is why it needs scrolling. I have placed it inside RecyclerView becouse I have other items like: header and footer. Is there any fix for that or I have to place WebView outside RecyclerView as full screen view?
I had the same issue with im.delight.android.webview.AdvancedWebView. And I found a solution eventually.
This options helped me:
isFocusable = false
isFocusableInTouchMode = false
I hope they'll help you too.
WebViews support scrolling and shouldn't be places inside RecyclerView, try getting the WebView outside your RecyclerView
I want to display the selected item as well as the previous and the next in a RecyclerView as I show in the image.
Here's what I need:
Any help is appreciated.
This is mi XML:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<android.support.v7.widget.RecyclerView
android:id="#+id/rv_operations"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
</RelativeLayout>
When you setting LayoutManager to your RecyclerView force it to have Horizontal layout:
LinearLayoutManager layoutManager
= new LinearLayoutManager(this, LinearLayoutManager.HORIZONTAL, false);
RecyclerView myList = (RecyclerView) findViewById(R.id.my_recycler_view);
myList.setLayoutManager(layoutManager);
try the following code snippet:
yourRecyclerView.setLayoutManager(new LinearLayoutManager(yourContext, LinearLayoutManager.HORIZONTAL, false));
I suggest you to use Fancy Cover Flow
<at.technikum.mti.fancycoverflow.FancyCoverFlow
android:layout_width="match_parent"
android:layout_height="match_parent"
fcf:maxRotation="45"
fcf:unselectedAlpha="0.3"
fcf:unselectedSaturation="0.0"
fcf:unselectedScale="0.4" />
When I put RecyclerView inside NestedScrollView then onBindViewHolder is calling for all row like say I have list which has size of 30 then onBindViewHolder is called for all 30 rows at one time even without scrolling
RecyclerView list;
LinearLayoutManager layoutManager = new LinearLayoutManager(getContext());
list.setLayoutManager(layoutManager);
layoutManager.setAutoMeasureEnabled(true);
list.setNestedScrollingEnabled(false);
list.addItemDecoration(new VerticalSpaceItemDecoration(5));
list.setAdapter(adapter);
my xml is
<android.support.v4.widget.NestedScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:fillViewport="true"
android:scrollbars="none"
app:layout_behavior="#string/appbar_scrolling_view_behavior">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#color/grey">
<android.support.v7.widget.RecyclerView
android:id="#+id/recycler_views"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="#+id/info"
android:layout_marginBottom="5dp"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:textAlignment="center"
android:visibility="visible"
/>
but if I remove NestedScrollView it's working properly.
I'm going to assume that since your are using appbar_scrolling_view_behavior you are trying to do something with AppBarLayout.
If so, you can use RecyclerView as a direct child of CoordinatorLayout and have support for AppBarLayout scrolling without nesting RecyclerView inside of NestedScrollView.
Try this: RecyclerView inside CoordinatorLayout (with AppBarLayout and CollapsingToolbarLayout):
<android.support.design.widget.CoordinatorLayout
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:fitsSystemWindows="true">
<android.support.design.widget.AppBarLayout
android:id="#+id/app_bar_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:fitsSystemWindows="true">
<android.support.design.widget.CollapsingToolbarLayout
android:id="#+id/collapsing_toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_scrollFlags="scroll">
<android.support.v7.widget.Toolbar
android:id="#+id/toolbar"
android:layout_width="match_parent"
android:layout_height="80dp"
android:background="#55FF00FF"
app:layout_collapseMode="none"/>
</android.support.design.widget.CollapsingToolbarLayout>
</android.support.design.widget.AppBarLayout>
<android.support.v7.widget.RecyclerView
android:id="#+id/recycler_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="#string/appbar_scrolling_view_behavior" />
</android.support.design.widget.CoordinatorLayout>
And in your Activity or CustomView:
RecyclerView list;
LinearLayoutManager layoutManager = new LinearLayoutManager(getContext());
list.setLayoutManager(layoutManager);
list.addItemDecoration(new VerticalSpaceItemDecoration(5));
list.setAdapter(adapter);
But you set android:layout_height for NestedScrollView to wrap_content - here, it's zero by default (because there no content for him at the moment of the declaration). Next, for RecyclerView you set android:layout_height to match_parent - which is at the moment is 0. Thus, all your items have 0 height.
Thus, you have such situation.
Solution: use solution above from #dkarmazi https://stackoverflow.com/a/37558761/3546306 or try to change parameter android:layout_height values.
It's right.Because you are using a ScrollView.ScrollView is not recyclable like RecyclerView or ListView.It will show all view contains these out of screen in one time.You should use a other layout instead.
I faced the same issue. After a bit of research fount the solution.
You need to make sure your recyclerview height is fixed by setting it to MATCH_PARENT. Or if its in a contraint layout then set height to 0dp and set the required height constrains.
Then set recyclerview.setHasFixedSize to true.
The onBindViewHolder will start getting called after this.