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"
Related
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
in my activity, i have three lists. after running the application, the screen is not scroll-able. i can scroll the list which is on top of others but i can't scroll the whole of page. I tried to add ScrollView into my xml layout but lint says that "The vertically scrolling ScrollView should not contain another vertically scrolling widget (ListView)".
How to make my screen scrollable?
Try this way
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout android:id="#+id/GlobalLayout"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<ListView android:id="#+id/ListView1"
android:choiceMode="multipleChoice"
android:layout_height="100dip"
android:layout_width="fill_parent" />
<ListView android:id="#+id/ListView2"
android:choiceMode="multipleChoice"
android:layout_height="100dip"
android:layout_width="fill_parent" />
<ListView android:id="#+id/ListView3"
android:choiceMode="multipleChoice"
android:layout_height="100dip"
android:layout_width="fill_parent" />
</LinearLayout>
</ScrollView>
<ScrollView
android:id="#+id/scrollView1"
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent" >
<ListView
android:id="#+id/listView1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1" >
</ListView>
</LinearLayout>
</ScrollView>
Scrollview supports one child layout so make the listview inside the scroll so you will get what you want.
It doesn't work because android don't know with which view he should scroll, so putting a listview in a scrollview its not a bright idea.
try to use visibilty attribute, use to HIDE the view that you finich to work with and set VISIBLE the new.
or use one ListView and try to populate and remove items after finishing and starting an instruction.
hope that help you
What you can do is that you can add header and footer into your list view by inflating them. Create three xml layououts and add them in listview using header and footer.
View headerView = View.inflate(this, R.layout.layout_name, null);
lv.addHeaderView(headerView);
use it before setting adapter. lv is listview.
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.
Is it possible to have a custom expandable list view in android with scrollview?
ListView already have scrollView associated with it, you can use MergeAdapter to achieve this
I don't think any of you got his question right! He is asking about the "expandable" list view. Anyways I also seem to be having the same doubt.
I still think the answer is NO.
You may be able to use custom views and them inflate them into an already existent layout element which will give you the same effect. And I think that solution will be better.
ExpandableListView has its own listview. You don't have to integrate another listview on it. Notice that if you have a long list, vertical scroll is associated automatically.
combination of listview withing scrollview is not happening to be good option. if you will place any listview within scroll view the listview will not scroll. Its seeming to be officialy said by google android programmer that this will be a bad user experience.
Of course, combination of expandable listview withing VERTICAL scrollview is not happening to be good option, but using it within HorizontalScrollView works impressive. I use this method in my program. User can horizontally scroll long strings.
<?xml version="1.0" encoding="UTF-8"?>
<RelativeLayout
android:id="#+id/RelativeView01"
android:layout_height="fill_parent"
android:layout_width="fill_parent"
xmlns:android="http://schemas.android.com/apk/res/android"
>
<Button
android:id="#+id/btnSaveSelection"
android:layout_alignParentLeft="true"
android:layout_width="100dip"
android:layout_height="50dip"
android:layout_alignParentBottom="true"
android:text="#string/SaveSelection"
android:focusable="true"
android:background="#drawable/android_button"
android:onClick="myClickHandler14" />
.........
<HorizontalScrollView
android:id="#+id/HorizontalScrollView01"
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:scrollbars="horizontal|vertical"
android:layout_above="#id/button_add_group"
android:layout_alignParentTop="true">
<LinearLayout android:id="#+id/LinearLayout02"
android:layout_width="wrap_content"
android:orientation="vertical"
android:layout_height="wrap_content">
<ExpandableListView android:id="#+id/android:list"
android:layout_width="750px"
android:layout_height="wrap_content"
android:groupIndicator="#android:color/transparent" />
<TextView android:id="#+id/android:empty"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#000000"
android:text="#string/no_data"/>
</LinearLayout>
</HorizontalScrollView>
</RelativeLayout>
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"