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.
Related
I use this tut http://www.androidhive.info/2013/07/android-expandable-list-view-tutorial/ for know how to use expanablelistview in android but i have a problem, many childviews of my form take a long text then it auto down to 2nd row. I want only single row, so i add a HorizontalScrollView to list_item.xml like this:
<HorizontalScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/lblListItem"
android:textSize="17dp"/>
</HorizontalScrollView>
It work but each child get a scroll,..aww (i know it'll happen but got no idea)
Some solution for this issue?
Thanks
It is not cleared If u don't want to show scrollbar then try this
<HorizontalScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:scrollbars="none">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/lblListItem"
android:singleLine="true"
android:textSize="17dp"/>
</HorizontalScrollView>
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.
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?
I have a LinearLayout with a number of TextView followed by a ListView at the bottom - see code below.
The problem is the TextView/CheckBox's take around 75% of the screen - ListView then has a scroll inside it at the bottom, not massively usable - how do I disable the ListView scroll and enable the whole LinearLayout Scroll. Please provide some example code.
<LinearLayout android:orientation="vertical"
android:layout_margin="5dip"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<RelativeLayout android:layout_width="fill_parent"
android:layout_margin="5dip"
android:layout_height="wrap_content"
android:background="#CCCCCC">
<TextView android:id="#+id/_text_title"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="#string/text1"
android:layout_marginTop="14dip"
android:textColor="#FFFFFF"
android:gravity="center_horizontal"
android:textSize="17dip"
android:textStyle="bold" />
<CheckBox ..../>
<CheckBox ..../>
<TextView android:id="#+id/_text_title" ..../>
<CheckBox ..../>
<CheckBox ..../>
<ListView .../>
</LinearLayout>
Never put a scrollable view inside another scrollable view. It will not work. if you run into such a problem you have a UI design flaw. An UI redesign/rethink is imminent.
Ok, So I found the solution to this.
I dont have the code to hand, but roughly speaking what I did was,
create new class extending ListView
Override the onMeasure method,
Using the data set I have - I know the hight of each row, I calculate the height of the list and set this manually.
I also faced the same problem. To remove this you have to put your list view in sap rate layout.
I am using following code to display button at the bottom of activity.
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
>
<Button android:id="#+id/btnGetMoreResults"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:text="Get more"
/>
</RelativeLayout>
and listview above it. when i display more data in listview this button pannel is moved down.can any one guide me how can i fix it at the bottom of activity?
any help would be appreciated.
The answer selected as correct is faulty, the button will hide the lower part of the list view. The correct way is to declare the button first and position the list above the button.
<Button android:id="#+id/btnGetMoreResults"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:text="Get more"
android:layout_alignParentBottom="true"/>
<ListView
...
android:layout_above="#id/btnGetMoreResults"/>
The android:layout_alignParentBottom attribute has to be declared in an element of the RelativeLayout not in the RelativeLayout himself (unless there is another RelativeLayout as a parent).
You should do something like this, with the ListView inside the RelativeLayout also :
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true">
<ListView ...>
<Button android:id="#+id/btnGetMoreResults"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:text="Get more"
android:layout_alignParentBottom="true" />
</RelativeLayout>
If you had, for example, all the scrollable elements in a ScrollView, you should do like the following:
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
style="#style/rootElement"
>
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
>
<!-- texts, buttons, images and anything that you want to scroll -->
</ScrollView>
<LinearLayout
android:orientation="vertical"
style="#style/footer"
android:id="#+id/footer"
android:layout_alignParentBottom="true"
>
</LinearLayout>
</RelativeLayout>
Note that if you want the footer to be fixed, then you shouldn't put it in the ScrollView, where the scrollable content will be placed. Make it child of RelativeLayout and set layout_alignParentBottom to true. Maybe you'll need to add a padding at the bottom of the ScrollView in this case (so that the last element do not get hidden by the footer).
The idea is similar for elements other than ScrollView