Android ListView not show scrollbar when fastscroll - android

When I scroll the list, fastscroll thumb is showed but the scrollbar thumb and track not showed.
Here is my XML code:
<ListView
android:id="#+id/list_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scrollbarTrackVertical="#drawable/bg_scroll"
android:scrollbarThumbVertical="#drawable/scroll_bar"
android:divider="#drawable/list_line"
android:fastScrollEnabled="true"`/>
My fastscroll thumb drawable is setted in styles.xml AppTheme.

Since you have set android:fastScrollEnabled="true" you need to set the fastScroll properties like android:fastScrollTrackDrawable="#drawable/"and 'android:fastScrollThumbDrawable="#drawable/". And also consider what #Gouse Mohiddin has said. You need to have enough rows inside to make it scrollable.

Please check the data you passed to list view because fast scroll is only displayed when you have more list items to scroll.
Make sure you have these lines in recycler view tag
app:fastScrollHorizontalThumbDrawable="#drawable/thumb_drawable"
app:fastScrollHorizontalTrackDrawable="#drawable/line_drawable"
app:fastScrollVerticalThumbDrawable="#drawable/thumb_drawable"
app:fastScrollVerticalTrackDrawable="#drawable/line_drawable">

Related

Reposition scroll in Horizontal Listview using RecyclerView

I have created horizontal ListView using RecyclerView:
<android.support.v7.widget.RecyclerView
android:id="#+id/horizontal_recycler_view"
android:scrollbars="horizontal"
android:layout_width="433px"
android:layout_height="76px"
/>
But the problem is I want to reposition the scrollBar, when I try to do that then everything goes wrong. I have tried to add these two lines to RecyclerView:
android:scrollbarStyle="outsideOverlay"
android:paddingBottom="10dp"
If I use those two lines then scrollBar does not go further away from the listview, instead it creates result similar in this image:
It just shrunks the whole listview's height. Does anyone have other ideas on how to reposition scrollBar or maybe I have messed soething up and I do not understand something?

ListView in android adds padding to headers same size as dividerHeight

I have a simple ListView in Android containing items, a headerView and a footerView. The headerView and footerView are added programatically to the ListView.
The xml for the ListView looks as follows:
<ListView
android:id="#+id/list"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:dividerHeight="8dp"
android:divider="#color/gray"
android:footerDividersEnabled="false"
android:headerDividersEnabled="false" />
This gives a gray divider of 8dp between each listitem which is exactly what I want. The problem is that it also adds a padding between the headerView and the first listitem with the same color as the theme background (white in my case), the padding is also the same height as the dividerHeight (8dp).
I though that the property headerDividersEnabled="true" would take care of this, from the reference:
android:headerDividersEnabled
When set to false, the ListView will not draw the divider after each
header view. The default value is true.
If I set headerDividersEnabled="true", a grey 8dp divider between the listitem and headerView is drawn, as expected.
From what i got from your question is you are trying to hide the grey lines between items ,if so try this.
To remove the separator between items in the same ListView, here is the solution:
getListView().setDivider(null);
getListView().setDividerHeight(0);
developer.android.com # ListView
Or, if you want to do it in XML:
android:divider="#null"
android:dividerHeight="0dp"
Add this in ListView
android:clipToPadding="false"
ListView will recycle its children as soon as they enter the padding area. The attribute clipToPadding only affects drawing

Handle click for recycle view parent

I have a recycle view horizontaly which sometimes contains one or two elements and may not cover entire screen.
I want to handle click for the rest of empty space on right but since by default recycler view is match parent the click listener on container does not work.
Is it possible to stop recycler taking click entirely and its parent container (say Linear Layout) handle click
<LinearLayout
android:id="#+id/container"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<android.support.v7.widget.RecyclerView
android:id="#+id/rv_friend_list"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:minHeight="#dimen/ad_detail_friend_recycle_min_height" />
</LinearLayout>
I have tried making recycler element as disabled and even whole recycler list clickable and focusable false.
Hey the problem lies with the fact that you are not able to set property wrap_content to the width of the recycler view(https://code.google.com/p/android/issues/detail?id=74772)
However there is a workaround for the same available here which is to set a custom layout manager which shall enable you to set the wrap_content property to the recycler-view. Now set a click listener on the linear-layout and you are good to go.
Now, there is another way which i'm not sure will work, but what if you set a onclicklistener on the recycler-view itself??;-)
Thanks to the new support library 23.2.0 this issue is fixed now.

Etsy's Android Staggered Gridview - drawSelectorOnTop

I'm trying to use Etsy's Staggered Gridview (https://github.com/maurycyw/StaggeredGridView), and I have it working mostly as expected, except I'm having an issue trying to get the selector to draw on top.
I've tried using mGridView.setDrawSelectorOnTop( true ); and android:drawSelectorOnTop="true" in the layout, but no success yet. Anyone happen to have solved this problem, or know if it's not possible with the library in its current state?
Etsy's StaggeredGrid frustratingly doesn't support item selector drawables. To work around this, set the selector on the GridView item, not the GridView itself.
In my current project, I wrap the GridView item in a FrameLayout, because a FrameLayout has an android:foreground attribute:
<FrameLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:foreground="?android:attr/selectableItemBackground">
<!-- Your item layout goes here. -->
</FrameLayout>
?android:attr/selectableItemBackground gives you the standard blue highlight. If you want, you can use your own state list drawable instead.

ListView populates from the bottom instead of from the top

I have a listView that expands upwards instead of downwards.
I have another listView on another page that works just fine and populates itself from the top -> bot.
Why does my listView start from the bottom instead of the top?
My XML
`
<ListView
android:id="#+id/list_view_showRegister"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_above="#+id/showRegister"
android:layout_alignParentLeft="true"
android:layout_marginTop="50dp"
android:clickable="false" >
</ListView>`
Your ListView is still actually populating from the top downwards. Just not from the top of the page.
You have set the layout_height="wrap_content" and the layout_above="#+id/showRegister". With the height being wrap_content, the view will only be as large as it's contents. Then, due to the fact you have used layout_above, it will be directly above another view.
The listview is not filling from the bottom, it is filling from the top (of the listview) - but the listview itself is only starting from halfway up the screen. Anything above the listview is not actually part of the listview, but empty space instead.
The solution is to either set the layout_height="match_parent", or remove the layout_above tag.
I know this is an old question but I hope this helps anyone else who may have found this issue via google.
Have a look a these links. Is it possible to make a ListView populate from the bottom?. populating from bottom.
Add new items to top of list view on Android?. Add new item at the top of list.
See for android:stackFromBottom attribute.

Categories

Resources