can we have list view within scrollview? - android

I have applied scroll view to the entire layout and that layout has one listview. when running the application in the emulator both scroll views are working one scroll view for entire layout and another scroll view for listview (both works fine). but when i installed my app in the phone only outer scroll view is working scroll view for listview is not working. Can any one please tell me the reason and solution for my problem.
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/ScrollView1"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#drawable/bg4"
android:orientation="vertical"
android:scrollbarAlwaysDrawVerticalTrack="true" >
<ListView
android:id="#+id/listViewTickets"
android:layout_width="match_parent"
android:layout_height="200dp"
android:layout_gravity="center_horizontal"
android:layout_marginTop="10dp" >
</ListView>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="right"
android:layout_marginBottom="70dp"
android:orientation="horizontal"
>
<Button
android:id="#+id/btnNew"
android:layout_width="80dp"
android:layout_height="30dp"
android:background="#drawable/btnnew" />
<Button
android:id="#+id/btnUpdate"
android:layout_width="80dp"
android:layout_height="30dp"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:background="#drawable/edit" />
</LinearLayout>
The content of list view is displayed dynamically.

I have found the youtube video Google I/O 2010 - The world of ListView an essential watch. In it it's mentioned to never use multiple scrolling widgets unless they scroll on a different axis.

A list view is already scrollable so you can't add it to a scroll view.
Here's a similar question and an answer from the Google engineer in charge of the ListView:
How can I put a ListView into a ScrollView without it collapsing?

Related

MvxListView not displaying horizontally

In my Android app I've created a vertical layout to hold a horizontal list of images (thumbnails) over top a larger view of a selected image from the list. For some reason I cannot get the horizontal list to display horizontally it only appears as a vertical list.
<LinearLayout
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_weight="15">
<LinearLayout
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1">
<Mvx.MvxListView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
local:MvxBind="ItemsSource Images"
local:MvxItemTemplate="#layout/image_item" />
</LinearLayout>
<ImageView
android:src="#drawable/BDSeal"
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:layout_margin="10.0dp"
android:id="#+id/imageView1" />
</LinearLayout>
In Android, the system ListViews are vertical only.
There are open source horizontal list views available - eg cheesebaron once provided http://blog.ostebaronen.dk/2012/12/horizontal-listview-for-mono-for-android.html - and I think this has been updated more recently.
Also some people use the PageAdapter to show this type of horizontally scrolling list.

Unable to scroll listView [duplicate]

This question already has answers here:
ListView inside ScrollView is not scrolling on Android
(27 answers)
Closed 3 months ago.
I am having a xml file in which UI elements are arranged in the following sequence. The data I am parsing is being populated on the listView but the listView is not scrollable.Please help me
ImageView
TextView
imageView
ListView
imageView
layout.xml
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/scrollView_description"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:fillViewport="true"
android:orientation="vertical" >
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#ffffff"
android:focusableInTouchMode="true"
android:orientation="vertical" >
<ImageView
android:id="#+id/imageView_now_playing"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:scaleType="fitXY" />
<TextView
android:id="#+id/textView_DailyLimit"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/imageView_now_playing"
android:layout_centerHorizontal="true"
android:layout_marginLeft="15dp"
android:layout_marginRight="15dp"
android:layout_marginTop="2dp"
android:textAppearance="?android:attr/textAppearanceMedium" />
<LinearLayout
android:id="#+id/linearLayout1"
android:layout_width="match_parent"
android:layout_height="200dp"
android:layout_below="#+id/button_PlayArea"
android:layout_marginTop="20dp"
android:background="#ffffff"
android:orientation="vertical" >
<ListView
android:id="#+id/listViewEpisodes"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:cacheColorHint="#000000"
android:divider="#android:color/black"
android:dividerHeight="5dp"
android:textColor="#000000" />
</LinearLayout>
<ImageView
android:id="#+id/button_Characters"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/linearLayout1"
android:layout_marginTop="20dp"
android:scaleType="fitXY"
android:src="#drawable/gallery" />
<ImageView
android:id="#+id/button_PlayArea"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/textView_DailyLimit"
android:layout_marginTop="20dp"
android:scaleType="fitXY" />
</RelativeLayout>
</ScrollView>
You are making a big mistake here by placing the Listview inside Scrollview. Remove Scrollview and UserRelativeLayout as the Top parent and the Listview will scroll.
Also a UX suggestion is never ever use two scrollable items in side
one another as user would never be able to know what has to be
scrolled. And similarly you won't be able to recognize what is user
trying to scroll.
Suggestion
You can do one thing. Just keep your TextView inside the Scrollview and below it keep your listview but don't make the whole layout scrollable. i.e. two elements can be scrolled but not the whole screen with scrollable elements.
Never put a listView inside a scrollView. Never ever.
Watch his great video to know more abt listView
http://www.youtube.com/watch?v=wDBM6wVEO70
ListView does not need inside the ScrollView to make it scrollable because ListView will be scrollable if the content is too long.
You can put listview inside scrollview. See this https://stackoverflow.com/a/18354096/942224
and set this value of listview
yourListView.setExpanded(true);

Android: Issue with several ExpandableListView in my layout

I have a main Scrollview layout with a LinearLayout including several elements:
ExpandableListView #1 (1 children for yet)
TextView
ExpandableListView #2 (1 children for yet)
Several text views
The issue I encounter is when I click on any of the ExpandableListView, le display by itself is not expanding.
You can see the non-expanded view in this screen-capture (not clikced yet):
https://plus.google.com/photos/101037819512700772601/albums/5870915782494751761/5870915784486932322
You can see the should be expanded view (once I clicked on the ExpandableListViews) in this screen captures:
https://plus.google.com/photos/101037819512700772601/albums/5870915782494751761/5870915780856077570
There you have my layout:
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<ExpandableListView
android:id="#+id/expandableView"
android:layout_width="match_parent"
android:layout_height="match_parent">
</ExpandableListView>
<TextView
android:id="#+id/providerNameView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="2dp"
android:text="ABCDEF1"
android:textSize="25sp"
android:textStyle="bold" />
<ExpandableListView
android:id="#+id/expandableView2"
android:layout_width="match_parent"
android:layout_height="match_parent">
</ExpandableListView>
<TextView
android:id="#+id/providerNameView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="2dp"
android:text="ABCDEF2"
android:textSize="25sp"
android:textStyle="bold" />
. . .
</LinearLayout>
</ScrollView>
Do you have a solution for my issue?
First things first. You can't nest multiple vertical scrolling views. Otherwise you're going to have a field day trying to override the appropriate touch events to get everything right.
If you need other views to scroll as the list scrolls, you can simply add header/footer views. If you need that to be 'sticky' a cursory Google search came up with Sticky headers library.

how to create a bouncable scrollview with header in android?

I want a bouncable scrollview (iPhone like) in my project. I find some articles about overscroll and use it like This class here. But i dont know how to set over scroll view as its header.
I also tried adding a view simply before my custom scroll view but it didn't work (codes at the end).
I need a view attached to scrollview how can i do this? any idea will be grateful.
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:background="#FF8080"
>
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
</LinearLayout>
<com.amix.tstsrc.MyScrollView
android:id="#+id/my_scrollView"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#8585FF">
<TextView
android:id="#+id/help_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#android:color/white" />
</LinearLayout>
</com.amix.tstsrc.MyScrollView>
Please go through https://github.com/Larphoid/android-Overscroll-ListView. I hope this is what you are looking for.
In case you want scrollview with header where header stays and the list scrolls and bounces then try to go for listview by using addHeaderView instead of Scrollview.

Android - How to enable full page scrolling on a layout with a ListView?

I have a layout with a ListView. The list scrolls fine, but sometimes the other content on the page needs to be bigger and either the list or the other content take up too much of the screen so I need it all to scroll.
Can that be done?
Here is the layout I have so far:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<include android:id="#+id/header"
layout="#layout/header"
android:layout_height="wrap_content"
android:layout_width="fill_parent"/>
<TextView
android:id="#+id/view_name"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Business:"
/>
<TextView
android:id="#+id/business_privacy"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Loading..."
/>
<TextView
android:id="#+id/think"
android:layout_width="fill_parent"
android:layout_marginTop ="5dp"
android:textColor="#color/light_best_blue"
android:paddingLeft="10px"
android:layout_height="wrap_content"
android:text="Fill out each section below"
/>
<ListView
android:id="#android:id/list"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#+id/label"
android:textSize="20px"
>
</ListView>
</LinearLayout>
What would be the way to make it easy for the user to be able to see both the text and the list even if the text takes up the whole screen? Can I make the text scrollable? It is especially bad in horizontal view so I think there must be some ux patters to make it play nicely.
Thanks for the advice!
1- Put textview which has a larger text in header of the list view so it get scroll with list...
or
2- put the textview in other scroll view with fixed size like 1/3 of the screen.
You could either make the content wrap, or wrap the content up using a HorizontalScrollView. Android docs on it can be found here.

Categories

Resources