I'm using an expandable list view in an alert dialog (custom).
I am setting the view for the list like this:
alertDialogBuilder.setView(myView);
However i notice that the list doesn't stretch to occupy the whole view and i have to scroll within that list as shown in the image below:
Here's my xml code as well:
<ExpandableListView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/listview"
android:layout_width="match_parent"
android:background="#android:color/white"
android:groupIndicator="#null"
android:scrollbars="none"
android:layout_height="wrap_content"
/>
Has anyone ever had this problem before or know how to tackle it, i could set the height of the expandable listview but i wan't to refrain from that.
Related
I have a layout, something like a page. I have a list view and at the bottom of the list i need to have a button. It has to be under the List View, not sticking at the bottom of the screen. (Like you have to scroll all the way down through the list to get that button.) The structure I am using:
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<ListView
android:id="#+id/show_list"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:dividerHeight="7dp"
android:paddingHorizontal="25dp"
android:scrollbars="none"
android:scrollingCache="false" />
<LinearLayout>
//My button here
</LinearLayout>
</LinearLayout>
</ScrollView>
MAIN ISSUE: Scrolling ends at the last item of ListView, Button stays out of screen. Why is that so? (I tried disabling list scrolling with isVerticalScrollBarEnabled, but it didn't make any difference.)
EDIT: Now, as I switched order of the button and the list, I found out that I am scrolling ListView, not ScrollView, so the issue is I need to do scrolling of ScrollView, not ListView. How to do that?
So I found out that ListView in a ScrollView is a bad practice, I used ListView footer feature instead, having button in the seperate layout, then adding it through code. It works perfectly.
My linear layout having two list views, when i add items in second list view, its not expanding. its getting scrolled automatically,
i have used match_parent in my linear layout, even though the second list view (getting scrolled instead of expanding) or the linear layout is not expanding.
Can anyone please help me to expand the list view or the linear layout.
problem in linear layout or the second list view?
but the first list view expanding properly.
fragment_one.xml
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:layout_weight="1"
android:descendantFocusability="blocksDescendants"
android:padding="10dip" >
<ListView
android:id="#+id/list_nation"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dip"
android:background="#B29090"
android:nestedScrollingEnabled="true">
</ListView>
<ListView
android:id="#+id/list_regional"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dip"
android:background="#4A9C67"
android:focusable="false"
android:nestedScrollingEnabled="true">
</ListView>
</LinearLayout>
When you add multiple scrolls in a single screen it always shows problems. Because they conflict with each other.
There are two solution for your problem.
If you want to keep your each listview to take half screen then add "weightsum = 100" in your main linear layout and set weight of both listviews to "50".
If you want your first list to scroll till end and at the end of first you want the second one to start scrolling, then calculate the height of your lists on run time and assign the calculated height to your listviews. Check this: Android: How to measure total height of ListView
I have a ListView inside of a HorizontalScrollView which I'm using as a small panel overlaying a fragment. It all would work as expected if the longest item were the top item. When the shortest is, the ListView's width takes on the width of that item and then there's no horizontal scrolling. The rest of the items are just cropped.
Here is the pertinent portions of the layout:
<HorizontalScrollView
android:id="#+id/vendorListContainer"
android:layout_width="180dp"
android:layout_height="match_parent"
android:layout_gravity="start"
android:background="#50FFFFFF"
android:visibility="gone" >
<ListView
android:id="#+id/vendorList"
android:layout_width="wrap_content"
android:layout_height="match_parent" />
</HorizontalScrollView>
I'm using the android.R.layout.simple_list_item_activated_1 as the item layout. Should I be using a custom layout with some special options chosen to fix this? I thought of just padding all the strings, but that's a hack I'd rather avoid. What am I doing wrong?
Now i going on with the MergeAdapter to show the list of data in vertical view and successfully showed it.Now what i need to show it in MergeAdapter horizontal list and also search a lot for MergeAdapter horizontal listview.
Is it possible to show listview in MergeAdapter horizontal view if there please help me.
Should achieve this by MergeAdapter horizontal listview.
There is no supported horizontal listView in android. I have no idea about MArgeAdapter but if you want to use Horizontal you need to constructer a xml like that
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:paddingLeft="#dimen/paddingLeft"
android:paddingTop="#dimen/paddingRight" >
<HorizontalScrollView
android:id="#+id/horizontalScrollView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingTop="#dimen/paddingTop">
<LinearLayout
android:id="#+id/scrollViewContainer"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal" >
</LinearLayout>
</HorizontalScrollView>
</LinearLayout>
and add views inside scrollViewContainer. Also check this How can I make a horizontal ListView in Android?
MergeAdapter has nothing to do with being vertical or horizontal. MergeAdapter is just an Adapter. The visual representation of the collection is up to the AdapterView, which can do scrolling vertically, horizontally, bi-directionally, diagonally, or not have scrolling at all.
So, find yourself an AdapterView that can serve as a horizontal ListView. Or, use RecyclerView for the horizontal-scrolling list and handle your merging by some other means.
I have a list view but at the begining i want to place a piece of text that will help the users to understand what't the purpose of that list. After that i want to display the list and i want to be srollable. The scroll i know how to do it, but the text part no. I've tryed to make two layouts, one for the text and another for the list, but my xml instantly becomes fill with errors.
That's my 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:background="#drawable/legislatie1"
android:orientation="vertical" >
<ListView
android:id="#+id/listView1"
android:layout_width="wrap_content"
android:layout_height="600dp"
android:layout_alignParentRight="true"
android:drawSelectorOnTop="true"
android:textSize="10pt" >
</ListView>
</RelativeLayout>
You can use a static TextView above the ListView if you choose, but it will not scroll with the ListView. An alternative is to add a Header to your ListView, which will scroll with the list. Header Tutorial