My scenario is like this:
<ScrollView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:scrollbars="vertical"
android:background="#ffffeb">
<LinearLayout
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:padding="10dp">
// Other stuff in between here..
<LinearLayout
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:paddingLeft="12dp"
android:paddingRight="12dp">
<Button
android:id="#+id/insert_ad_ad_information_category_and_type_button"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="6dp"
android:text="#string/insert_ad_ad_information_category_and_type_button"/>
<ListView
android:id="#+id/insert_ad_ad_information_parameters_frame"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#ffffeb"
android:cacheColorHint="#00000000"
android:divider="#00000000"
android:dividerHeight="0dp"
android:scrollbars="none"
android:listSelector="#android:color/transparent"/>
The problem I have is that I can't get my ListView to get the right height that I want.
I'll add a couple of components with my custom BaseAdapter class and everything there works as intended.
But when I then debug my application I can only see 1,5 out of 3 components in the list and the rest is hidden further down in the ListView.
But how can I make my ListView calculate how many components I have and get it to show all my components directly without having too scroll down?
Another thought is if I could populate any other kind of View with my BaseAdapter? Because the only reason I am using ListView is because of the setAdapter() method.
Appreciate all thoughts and comments :)
You cannot have a ListView in a ScrollView. Thats where the issue is.
As has been said you can't use ListView inside ScrollView.
If you want your listview have different types of items and scroll those with "normal" items
you do in fact need custom adapter. You can base it on BaseAdapter if you like
Adapter has to support your item types, and inflate appropriate layouts,
Related
I want to display a list of lists My data is an ObservableCollection where the SomeClass has another ObservableCollection in it.
Here is the code:
This is the main list:
<Mvx.MvxListView
android:id="#+id/MenuList"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
local:MvxBind="ItemsSource Path=Dishes"
local:MvxItemTemplate="#layout/menuitemtemplate"
android:background="#color/backgroundlightgray"
android:layout_weight="1" />
Here is the item template which has another list inside it
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:local="http://schemas.android.com/apk/res/Com.TasteITAndroidClient"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:minWidth="25px"
android:minHeight="25px">
<TextView
android:text="Text"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/textView1"
android:gravity="right"
android:textSize="16dp"
android:textStyle="bold"
android:textColor="#ff000000"
android:background="#color/white"
android:padding="10dp" />
<Mvx.MvxListView
android:id="#+id/CategoryDishes"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
local:MvxBind="ItemsSource Path=Items"
local:MvxItemTemplate="#layout/userpagedishtemplate"
style="#style/ToolBarImage"
android:background="#color/backgroundlightgray"
android:layout_below="#+id/textView1"
android:layout_marginTop="5dp" />
The userpagedishtemplate displays the item.
Basically it works but I am getting very small sized lists which show 1-2 items although I specified height=wrap_content on the subList.
Have I missed something? should I be doing something else?
Thanks
Amit
Placing a ListView that scrolls vertically inside another ListView which scrolls vertically is likely to cause touch area confusion for your users - which list scrolls...
If you really want a list within a list then you cab use the layout you've started on - but you will probably need to give the inner lists some assistance with their vertical sizing - something more than wrap_content
Alternatively, for very small inner lists, you could consider switching to MvxLinearLayout.
Alternatively, you could consider making the inner lists scroll horizontally.
Alternatively, you could consider collapsing your lists into a single list using a polymorphic-aware adapter to determine whether to show a header cell or an inner cell.
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 have a GridView that displays items, each item is a ListView.
the problem is that I can't scroll the ListView items, seems like the GridView is obtaining the focus or preventing it from the ListViews
is there a workaround for this ?
thanks
**
EDIT:
**
here's my activity layout
<GridView
android:id="#+id/grid"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:verticalSpacing="35dp"
android:horizontalSpacing="10dp"
android:numColumns="auto_fit"
android:columnWidth="300dp"
android:stretchMode="columnWidth"
/>
</LinearLayout>
each gridview item has the following layout:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
>
<ListView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:id="#+id/list"
/>
</LinearLayout>
set attribute android:scrollingCache="true" in your ListView
<ListView android:id="#+id/android:list"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:scrollingCache="true"
android:layout_weight="1" />
You cannot have a scrollable child view within a parent view that is scrollable. Google does not recommend it... and it's really messy. Read this
There have been people who've been trying to do a workaround (which doesn't look pretty), but I doubt it will work for you. But you can read it anyways and see if you can make it work for you. Enjoy.
One of the main reasons why it wont work is because of the way scrollable views handle touch. There's a method called dispatchTouchEvent() and onInterceptTouchEvent() that decides whether to intercept the touch event or pass it to it's children. For scrollable views, they will always intercept "swipe" movements. So it will never go to your children.
You can try to modify it, but if you think about it, how will you know if you're trying to scroll the parent or if you're trying to scroll the child? Imagine if the one of your scrollable children ends up taking the width of your screen, but then you want to scroll your parent, how will you manage that?
Summary:
it's not recommended .... if you really insist... then go ahead and write your own custom view to handle the logic. But i guarantee you it wont be pretty and will almost never work for all use cases.
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 little problem with a ScrollView. I have a layout for an activity which is made with a ScrollView. This scrollview contains two ListViews.
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/rootViewGroup" android:layout_width="fill_parent"
android:layout_height="wrap_content" android:scrollbars="vertical">
<LinearLayout android:orientation="vertical"
android:gravity="top" android:layout_width="fill_parent"
android:layout_height="wrap_content" android:background="#drawable/cmb_bg">
<ListView android:id="#+id/accountsListView"
android:layout_width="fill_parent"
android:layout_height="wrap_content" android:scrollbars="none" />
<ListView android:id="#+id/cardsListView"
android:layout_width="fill_parent"
android:layout_height="wrap_content" android:scrollbars="none" />
</LinearLayout>
In the onCreate method of my activity I compute ListViews height according their contents.
During execution, on activity launch, ScrollView is already scrolled a bit.
So I tried, at the end of onCreate to call method scrollTo(0, 0), but it does not change anything.
Any ideas?
AHHH!!! Remove ScrollView and leave only ONE ListView in your activity. It's not intended to work this way
.If you want to have different content in your ONE listView - modify your adapter, or change the UI
But never, ever put different scrollable containers on the same screen/inside each other
here is a related post.
http://groups.google.com/group/android-developers/browse_thread/thread/e7c8df374fe31733#
In theory you can slap two listview on the screen, but expect things to be weird. And i would really redesign it with with either separators or expanders or just with one ListView.