I have a standard ListView. It's not displaying the scrollbar track thumb though. Is there some special setting you need to set in order to show the scrollbars? My definition looks like this:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<ListView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:dividerHeight="1dip" />
</LinearLayout>
The listview has data, and it has enough items to scroll.
Thanks
Try either including:
android:scrollbars="vertical"
http://developer.android.com/reference/android/view/View.html#attr_android:scrollbars
or:
android:layout_height="wrap"
Related
I created horizontal scrollable listview. And I can populated from db without any problem. The problem is; the entire length of the items are setted to the length of the first item.
Like this
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<HorizontalScrollView
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<ListView
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
</HorizontalScrollView>
</RelativeLayout>
Simple solution to this problem is to use Recyclerview instead of List View.
Adding HorizontalScrollview to LinearLayout will not work.
I have already tried many solutions posted here
after a lot of search I come to this point my solution was Recyclerview.
And from here i learned,How to use this.
You need to make listView height match the parent
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<HorizontalScrollView
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<ListView
android:layout_width="match_parent"
android:layout_height="match_parent"/>
</HorizontalScrollView>
</RelativeLayout>
I am interested in creating a screen composed of a transparent header and a listview that scrolls behind the header. I have this working with one flaw; the FAST scroll bar also draws underneath header.
For some reason, the fastscrollbar doesn't seem to respect the scrollbarStyle applied to the list view. You'll notice in the image below that the normal scroll bar works fine, but the powerscroll bar is behind the transparent header.
Unfortunately the listviews I am using will often have hundreds of items, so the fastscrollbar is a necessity. Is there some way to set the "fastscrollStyle" that is not documented? I am open to any suggestions! Thank you.
Here is the layout XML for reference:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<ListView
android:id="#+id/myListView"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:clipToPadding="false"
android:fastScrollEnabled="true"
android:scrollbars="vertical"
android:scrollbarStyle="insideOverlay"
android:paddingTop="50dp"/>
<TextView android:text="My Header"
android:gravity="center"
android:background="#8fff0000"
android:layout_width="fill_parent"
android:layout_height="50dp"/>
</RelativeLayout>
This was fixed in KitKat for ListView, however GridView still appears to exhibit this problem. Google?
The best solution is to separate your listview from the other layouts, where the main relativelayout view is the parent and other layouts are the children.
EX.
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<RelativeLayout
android:id"#+id/layoutHeader"
android:layout_width="fill_parent"
android:layout_height="50dp"
android:layout_alignParentTop="true">
<TextView android:text="My Header"
android:gravity="center"
android:background="#8fff0000"
android:layout_width="fill_parent"
android:layout_height="50dp"/>
</RelativeLayout>
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="+id/layoutHeader">
<ListView
android:id="#+id/myListView"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:clipToPadding="false"
android:fastScrollEnabled="true"
android:scrollbars="vertical"
android:scrollbarStyle="insideOverlay"
android:paddingTop="50dp"/>
</RelativeLayout>
</RelativeLayout>
This bug appears to be fixed in 4.4. In older versions however, there appears to be no known workaround other than leaving padding at 0.
I want to add a Expandable List View and a normal list view in this XML layout when I tried to show the both Expandable List View and a normal list only showing the expandable listview.
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
tools:context=".MainActivity"
android:orientation="vertical" >
<ExpandableListView
android:id="#+id/expandableListView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1" >
</ExpandableListView>
<ListView
android:id="#+id/list_evevnt"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
/>
</LinearLayout>
I am afraid you can't use both lists like that ... The way I see it, you have 2 options:
Either you'll add the second listview items in the first expandablelistview by extending the adapter class: for each item in this expandable that belongs to second listview, you'll have to set child count to zero so you will not have anything to expand. In ExpandableListAdapter#getGroupView() you can return the View from second listview adapter getView
There is a project created by Mark Murphy (aka CommonsWare), CWAC MergeAdapter that allows merging different listview and views in a single UI component. Since ExpandableListView is a ListView, then in theory it should work. I used this project successfully but without ExpandableListViews... If it works with these, please let me know
I hope it helps!
Try this......
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
androidrientation="vertical" >
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
>
<ExpandableListView
android:id="#+id/expandableListView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
>
</ExpandableListView>
</LinearLayout>
<ListView
android:id="#+id/list_evevnt"
android:layout_width="match_parent"
android:layout_height="fill_parent"
/>
</LinearLayout>
Use This
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
tools:context=".MainActivity"
android:orientation="vertical"
android:weigthSum="1" >
<LinearLayout android layout_weight=0.5
android:layout_height="0dp"
android:layout_width="fill_parent">
<ExpandableListView
android:id="#+id/expandableListView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1" >
</ExpandableListView>
</LinearLayout>
<LinearLayout android layout_weight=0.5
android:layout_height="0dp"
android:layout_width="fill_parent">
<ListView
android:id="#+id/list_evevnt"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
/>
<LinearLayout>
</LinearLayout>
you can't put 2 list views like that because when you scroll only the first list view will be scrolled .try changing your layout_height of expandablelistview to a specific dip it may help.
Try assigning a android:layout_weight to the ListView element as well. I think you have to have one since you set one for the ExpandableListView.
I used this tutorial for expandable list view, may this will helpful for you. good luck.
I think you should assign
android:layout_width="0px" for both views and assign
android:layout_weight for listview as well.
layout_weight won't work properly without layout_width set to 0px
i have seen a lot of android apps those have a ListView that some differences with my ListViews. in theire ListView Scroll bar seen like this:
in picture above when you scroll your list that scroll bar will be shown and u can touch on it and scroll easier.
but in my app seen like this:
this is my layout xml code:
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:paddingBottom="4dp"
android:text="#string/do"
android:textSize="16dp" />
<ListView
android:id="#+id/lv"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#drawable/main_background"
>
</ListView>
</LinearLayout>
i had googled many times but i didnt find any trick. can anybody help me how i can make my scroll like picture one?
You can add these lines in your listview. It worked for me.
android:fastScrollEnabled="true"
android:scrollbars="none
set android:fastScrollEnabled="true" in properties of the listview.
Also if you want fast scroll thumb to be visible always, set android:fastScrollAlwaysVisible="true"
then, in your xml definition of the listview, you would have something like this:
<ListView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:fastScrollAlwaysVisible="true"
android:fastScrollEnabled="true" >
</ListView>
Hi Use This attribute in your ListView which you declare in you layout file.
android:scrollbars="none"
I am having an issue that make me crazy
I have a listview with WebView inside. So I created a custom listview.
The WebView forbid me to click so I created a webviewclicklistener.
My problem was that when I display some images, my webviews are "shaking" as if it wants to load the image a thousand times.
In fact I discovered that the height size of some elements change like every seconds, that give a feeling of shake.
The only way I found to fix it is to give a layout:height value for my listview.
My new problem is that when I put for exemple 600dip, I have a scrollbar, but I can't look at the end of my listviews.
If I put like 1000dip, I don't have scroll bar and I can't see the end of my list neither.
Here is my layout
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent" android:layout_height="fill_parent"
android:orientation="vertical" android:background="#drawable/woodbackground"
android:layout_weight="1">
<TextView android:background="#android:color/transparent"
android:layout_width="fill_parent" android:layout_height="wrap_content"
android:hint="Question" android:textSize="30px"></TextView>
<ScrollView android:layout_width="fill_parent"
android:layout_height="wrap_content" android:orientation="vertical">
<WebView android:id="#+id/wvplquestion" android:layout_height="wrap_content"
android:layout_width="fill_parent"></WebView>
</ScrollView>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:background="#android:color/transparent" android:layout_width="fill_parent"
android:layout_height="wrap_content" android:orientation="vertical"
android:layout_weight="1">
<TextView android:background="#android:color/transparent"
android:layout_width="fill_parent" android:layout_height="wrap_content"
android:hint="Select Answer" android:textSize="30px"></TextView>
<ListView android:id="#+id/lvquestion" android:layout_width="fill_parent"
android:layout_height="600dip" android:prompt="#string/selectp" />
</LinearLayout>
And my custom listview layout
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent" android:layout_height="wrap_content"
android:orientation="vertical" android:padding="3dip">
<WebView android:id="#+id/weblistview" android:layout_width="fill_parent"
android:layout_height="wrap_content"></WebView>
Thanks for your help
maybe you can try to change your listview layout height. Instead of wrap content, put a fixed height. I don't know if it will be working, but you can try it. I'd a problem similar to yours and I solved it like this.
I hope it will work. Good luck ;)
Seems it mostly happens when several webviews contained into one scrollview. Seems at least first webviews should have fixed height.