I have a WebView at the bottom of view in ViewPager... When I slide through the items of ViewPager. The View moves on down. (I guess the focus goes to webview)
I am not sure whether this is due to WebView.
Loading the webview with html data using
webView.loadDataWithBaseURL(null, data, "text/html","utf-8",null);
It's annoying when the page moves down every time the next item is loaded. I have an ImageView at the top of the View
Any pointers?
here is the xml:
<ScrollView
android:id="#+id/scroll_view_1"
style="#style/some_style"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:fadingEdge="none" >
<LinearLayout
android:id="#+id/linear_layout_1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#drawable/some_drawable"
android:orientation="vertical" >
<RelativeLayout
android:id="#+id/relative_layout_1"
android:layout_width="fill_parent"
android:layout_height="250dp"
android:paddingLeft="5dip"
android:paddingRight="5dip" >
<LinearLayout
android:id="#+id/linear_layout_2"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_marginTop="5dip"
android:gravity="center" >
<PageIndicator
android:id="#+id/page_indicator"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:padding="10dip" />
</LinearLayout>
<RelativeLayout
android:id="#+id/relative_layout_2"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:visibility="visible" >
<TextView
android:id="#+id/text_view_1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:layout_marginRight="10dip"
android:text="1/50"
android:textColor="#000000"
android:textSize="16sp" />
<ImageView
android:id="#+id/image_view_1"
android:layout_width="35dip"
android:layout_height="35dip"
android:layout_marginRight="5dip"
android:layout_toLeftOf="#id/text_view_1"
android:scaleType="centerInside"
android:src="#drawable/some_drawable_3" />
<ImageView
android:id="#+id/image_view_2"
android:layout_width="35dip"
android:layout_height="35dip"
android:layout_marginRight="5dip"
android:layout_toLeftOf="#id/image_view_1"
android:scaleType="centerInside"
android:src="#drawable/some_drawable_4" />
</RelativeLayout>
</RelativeLayout>
<RelativeLayout
android:layout_width="relative_layout_3"
android:layout_height="wrap_content"
android:background="#f8f8f8"
android:gravity="center_vertical"
android:orientation="horizontal"
android:paddingBottom="5dip"
android:paddingTop="5dip" >
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:gravity="center_vertical" >
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:scaleType="centerInside"
android:src="#drawable/some_drawbale_2" />
<TextView
android:id="#+id/text_view_2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginLeft="6dip"
android:gravity="left|center_vertical"
android:paddingLeft="3dip"
android:paddingRight="7dip"
android:text="$121.00"
android:textColor="#000000"
android:textSize="16sp"
android:textStyle="bold" />
<Button
android:id="#+id/button_1"
android:layout_width="95dip"
android:layout_height="30dip"
android:layout_gravity="center_vertical"
android:layout_marginLeft="15sp"
android:background="#drawable/some_drawable_5"
android:gravity="center"
android:textSize="15dip" />
</LinearLayout>
</RelativeLayout>
<TextView
android:id="#+id/text_view_3"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="10dip"
android:layout_marginRight="10dip"
android:layout_marginTop="10dip"
android:gravity="left"
android:lineSpacingExtra="2dip"
android:text="Some Text"
android:textColor="#000000"
android:textSize="16sp"
android:textStyle="bold" />
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:paddingBottom="10dip"
android:paddingTop="15dip" >
<WebView
android:id="#+id/web_view"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="10dip"
android:layout_marginRight="10dip"
android:focusable="false"/>
</LinearLayout>
</LinearLayout>
</ScrollView>
I had the same kind of issue. And adding this attribute to the top most linear layout solved the issue. try this,
android:descendantFocusability="blocksDescendants".
In your case add this to your Linear Layout inside the ScrollView and check.
Related
I'm trying to create the following display, where the text scrolls and the other elements are fixed to the bottom of the screen:
However, it is appearing as follows, where the text doesn't scroll and it's pushing the elements off the screen.:
This is the layout I'm using:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/widget32"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center">
<ScrollView
android:id="#+id/scroller"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<TextView
android:id="#+id/txtTC"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="20sp"
android:paddingLeft="20dp"
android:layout_alignParentLeft="true" />
</ScrollView>
<CheckBox
android:id="#+id/chkBox"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_gravity="center"
android:text="Don't Show Again"
android:layout_below="#+id/scroller" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_below="#+id/chkBox"
android:layout_alignParentBottom="true">
<RelativeLayout
android:id="#+id/btnCancel"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:orientation="vertical"
android:layout_weight="1">
<ImageButton
android:id="#+id/imgCancel"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:paddingTop="0dip"
android:src="#drawable/stop"
android:paddingBottom="5dip"
android:paddingRight="5dip"
android:background="#drawable/common_button" />
<TextView
android:id="#+id/txtCancel"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:singleLine="true"
android:layout_below="#id/imgCancel"
android:layout_centerHorizontal="true"
android:layout_marginTop="30dp"
android:text="OK"
android:textStyle="bold" />
</RelativeLayout>
</LinearLayout>
</RelativeLayout>
What do I need to do to make the text scroll and the other elements fixed to the bottom of the screen?
Try replacing this xml code and apply images where you need
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/widget32"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#5555"
android:gravity="center"
android:orientation="vertical"
android:padding="25dp" >
<TextView
android:id="#+id/textView1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:text="Terms and Conditions"
android:textAppearance="?android:attr/textAppearanceLarge" />
<ScrollView
android:id="#+id/scroller"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1" >
<TextView
android:id="#+id/txtTC"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:paddingLeft="20dp"
android:textSize="20sp" />
</ScrollView>
<CheckBox
android:id="#+id/chkBox"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="#+id/scroller"
android:layout_gravity="center_vertical"
android:text="Don't Show Again" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_below="#+id/chkBox"
android:layout_alignParentBottom="true">
<RelativeLayout
android:id="#+id/btnCancel"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:orientation="vertical"
android:layout_weight="1">
<ImageButton
android:id="#+id/imgCancel"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:paddingTop="0dip"
android:paddingBottom="5dip"
android:paddingRight="5dip" />
<TextView
android:id="#+id/txtCancel"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:singleLine="true"
android:layout_below="#id/imgCancel"
android:layout_centerHorizontal="true"
android:layout_marginTop="30dp"
android:text="OK"
android:textStyle="bold" />
</RelativeLayout>
</LinearLayout>
</LinearLayout>
You should add the ScrollView Containing the TextView inside a Layout(Linear would do). I hope it helps
There is a list view and other text views in my screen.
I want to show the list in whole the screen and other elements in the bottom of the list.
Below is the code I used.
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/relative_layout"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#drawable/background_light_blue" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#drawable/background_light_blue"
android:orientation="vertical" >
<LinearLayout
android:id="#+id/header1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#layout/header_gradients"
android:orientation="vertical"
android:paddingBottom="8dip"
android:paddingTop="8dip" >
<TextView
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_marginLeft="10dip"
android:layout_weight="1"
android:gravity="center"
android:text="#string/shopping_cart"
android:textColor="#color/white"
android:textSize="15sp"
android:textStyle="bold" />
</LinearLayout>
<ScrollView
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#drawable/background_light_blue"
android:orientation="vertical" >
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="5dip"
android:layout_marginRight="5dip"
android:layout_marginTop="5dip"
android:background="#color/white"
android:orientation="horizontal"
android:padding="5dp" >
<TextView
android:id="#+id/purchase_order"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="6dp"
android:layout_marginTop="2dp"
android:text="Requisitioner"
android:textColor="#color/black"
android:textSize="15sp"
android:typeface="sans" />
<TextView
android:id="#+id/requisitioner"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="#id/purchase_order"
android:layout_marginBottom="3dp"
android:layout_marginLeft="6dp"
android:layout_marginTop="5dp"
android:text="Requisitioner"
android:textColor="#color/black"
android:textSize="15sp" />
<ImageView
android:id="#+id/imageView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:contentDescription="#string/image"
android:src="#drawable/shopping_cart" />
</RelativeLayout>
<TextView
android:id="#+id/products_and_services"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="3dp"
android:layout_marginTop="15dp"
android:gravity="center_horizontal"
android:text="#string/products_and_services"
android:textColor="#color/black"
android:textSize="17sp"
android:textStyle="bold" />
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<LinearLayout
android:id="#+id/lr1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical" >
<ListView
android:id="#android:id/list"
android:layout_width="wrap_content"
android:layout_height="0dp"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:layout_weight="0.12" >
</ListView>
</LinearLayout>
<LinearLayout
android:id="#+id/pagingPanel"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="#id/lr1"
android:background="#drawable/background_light_blue"
android:orientation="vertical" >
<TextView
android:id="#+id/note_to_approver"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="3dp"
android:layout_marginTop="10dp"
android:gravity="center_horizontal"
android:text="#string/note_to_approver"
android:textColor="#color/black"
android:textSize="17sp"
android:textStyle="bold" />
<TextView
android:id="#+id/note"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:layout_marginTop="2dp"
android:background="#color/white"
android:maxLines="10"
android:padding="5dp"
android:text="hijnjn"
android:textColor="#color/black"
android:textSize="15sp"
android:typeface="sans" />
<TextView
android:id="#+id/approver"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="1dp"
android:layout_marginTop="15dp"
android:gravity="center_horizontal"
android:text="#string/approvers"
android:textColor="#color/black"
android:textSize="17sp"
android:textStyle="bold" />
<Button
android:id="#+id/approvers"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:layout_marginTop="5dp"
android:background="#drawable/options_menu"
android:drawableRight="#drawable/arrow_right"
android:gravity="left|center"
android:text="#string/approvers"
android:textColor="#color/black"
android:textSize="16sp"
android:textStyle="bold"
android:typeface="sans" />
</LinearLayout>
</RelativeLayout>
</LinearLayout>
</ScrollView>
</LinearLayout>
<LinearLayout
android:id="#+id/relativeLayout1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:background="#layout/btn_background" >
<Button
android:id="#+id/release_button"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginBottom="5dp"
android:layout_marginLeft="15dp"
android:layout_marginRight="15dp"
android:layout_marginTop="5dp"
android:layout_weight="1"
android:background="#drawable/btn_blue"
android:text="Approve(1)/Reject(0)"
android:textColor="#color/white"
android:textSize="15sp"
android:textStyle="bold" />
</LinearLayout>
</RelativeLayout>
My requirement: Now the list is scrolling within the given area. I want to show in the whole screen and the scrolling should be only for the screen.
Please help me to do this.
You should not put a Vertically scrolling widget/view (ListView) in another vertically scrolling view (ScrollView). Though there are a few ways mentioned here and here which might help you achieve what you wish but that will increase the CPU load.
I am working on my first android app and one issue that I have not been able to find the solution is with the relative layout and footer bar.
I have set up a relative layout with a button bar at the bottom. It works find if there is enough content in the other linear layout; however, when there is not enough content to fill out the page, the content is aligned at the bottom on top of the button bar. I would like it to be aligned at the top with the button bar remaining on the bottom. I have tried every align top option I can find and setting the content height to fill_parent/match_parent, but all of those cause the items inside of the linear layout to disappear.
How can I fix this?
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/ViewPost"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#c9c9c9" >
<LinearLayout
android:id="#+id/bottom_control_bar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true" >
<Button
android:id="#+id/btnComment"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1.0"
android:drawableLeft="#drawable/content_new_event"
android:paddingBottom="2dip"
android:paddingLeft="8dip"
android:paddingRight="8dip"
android:paddingTop="2dip"
android:text="#string/BtnComment"
android:textColor="#797979"
android:textSize="14sp" />
<Button
android:id="#+id/btnMeToo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1.0"
android:drawableLeft="#drawable/social_add_group"
android:paddingBottom="2dip"
android:paddingLeft="8dip"
android:paddingRight="8dip"
android:paddingTop="2dip"
android:text="#string/BtnMeToo"
android:textColor="#797979"
android:textSize="14sp" />
<Button
android:id="#+id/btnFlag"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1.0"
android:drawableLeft="#drawable/flag"
android:paddingBottom="2dip"
android:paddingLeft="8dip"
android:paddingRight="8dip"
android:paddingTop="2dip"
android:text="#string/BtnFlag"
android:textColor="#797979"
android:textSize="14sp" />
<Button
android:id="#+id/btnShare"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1.0"
android:drawableLeft="#drawable/social_share"
android:paddingBottom="2dip"
android:paddingLeft="8dip"
android:paddingRight="8dip"
android:paddingTop="2dip"
android:text="#string/BtnShare"
android:textColor="#797979"
android:textSize="14sp" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_above="#id/bottom_control_bar"
android:layout_marginBottom="5dip"
android:layout_marginLeft="10dip"
android:layout_marginRight="10dip"
android:layout_marginTop="10dip"
android:background="#ffffff"
android:gravity="top"
android:orientation="vertical"
android:weightSum="1.0" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal" >
<TextView
android:id="#+id/ticket_id"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:visibility="gone" />
<ImageView
android:id="#+id/ticket_owner_image2"
android:layout_width="50dp"
android:layout_height="50dp"
android:layout_marginLeft="1dp"
android:layout_marginTop="1dp"
android:background="#797979"
android:contentDescription="#string/StdImageDesc"
android:padding="1dp"
android:scaleType="fitXY"
android:src="#drawable/picture" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<TextView
android:id="#+id/ticket_owner_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="10dip"
android:layout_marginTop="5dip"
android:paddingLeft="5dip"
android:textColor="#595959"
android:textSize="10sp" />
<TextView
android:id="#+id/ticket_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="10dip"
android:layout_marginTop="2dip"
android:paddingLeft="5dip"
android:textColor="#595959"
android:textSize="14sp" />
<TextView
android:id="#+id/ticket_create_date"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="10dip"
android:layout_marginTop="2dip"
android:paddingLeft="5dip"
android:textColor="#595959"
android:textSize="10sp" />
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="center" >
<TextView
android:id="#+id/ticket_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal|center_vertical"
android:layout_margin="5dip"
android:textColor="#595959"
android:textSize="14sp" />
</LinearLayout>
<ListView
android:id="#+id/commentlist"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:cacheColorHint="#00000000"
android:divider="#b5b5b5"
android:dividerHeight="1dp" />
</LinearLayout>
</RelativeLayout>
try the following and let me know if this what you want to achieve:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/ViewPost"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#c9c9c9" >
<ListView
android:id="#+id/commentlist"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:cacheColorHint="#00000000"
android:layout_below="#+id/linear1"
android:layout_above="#+id/bottom_control_bar"
android:divider="#b5b5b5"
android:dividerHeight="1dp" />
<LinearLayout
android:id="#+id/bottom_control_bar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true" >
<Button
android:id="#+id/btnComment"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1.0"
android:drawableLeft="#drawable/dummy_heyzooka_icon_blue"
android:paddingBottom="2dip"
android:paddingLeft="8dip"
android:paddingRight="8dip"
android:paddingTop="2dip"
android:text="aa"
android:textColor="#797979"
android:textSize="14sp" />
<Button
android:id="#+id/btnMeToo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1.0"
android:drawableLeft="#drawable/dummy_heyzooka_icon_blue"
android:paddingBottom="2dip"
android:paddingLeft="8dip"
android:paddingRight="8dip"
android:paddingTop="2dip"
android:text="dd"
android:textColor="#797979"
android:textSize="14sp" />
<Button
android:id="#+id/btnFlag"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1.0"
android:drawableLeft="#drawable/dummy_heyzooka_icon_blue"
android:paddingBottom="2dip"
android:paddingLeft="8dip"
android:paddingRight="8dip"
android:paddingTop="2dip"
android:text="ff"
android:textColor="#797979"
android:textSize="14sp" />
<Button
android:id="#+id/btnShare"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1.0"
android:drawableLeft="#drawable/dummy_heyzooka_icon_blue"
android:paddingBottom="2dip"
android:paddingLeft="8dip"
android:paddingRight="8dip"
android:paddingTop="2dip"
android:text="ff"
android:textColor="#797979"
android:textSize="14sp" />
</LinearLayout>
<LinearLayout
android:id="#+id/linear1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_marginBottom="5dip"
android:layout_marginLeft="10dip"
android:layout_marginRight="10dip"
android:layout_marginTop="10dip"
android:background="#ffffff"
android:gravity="top"
android:orientation="vertical"
android:weightSum="1.0" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="top"
android:orientation="horizontal" >
<TextView
android:id="#+id/ticket_id"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:visibility="gone" />
<ImageView
android:id="#+id/ticket_owner_image2"
android:layout_width="50dp"
android:layout_height="50dp"
android:layout_marginLeft="1dp"
android:layout_marginTop="1dp"
android:background="#797979"
android:contentDescription="ada"
android:padding="1dp"
android:scaleType="fitXY"
android:src="#drawable/dummy_heyzooka_icon_blue" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<TextView
android:id="#+id/ticket_owner_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="10dip"
android:layout_marginTop="5dip"
android:paddingLeft="5dip"
android:textColor="#595959"
android:textSize="10sp" />
<TextView
android:id="#+id/ticket_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="10dip"
android:layout_marginTop="2dip"
android:paddingLeft="5dip"
android:textColor="#595959"
android:textSize="14sp" />
<TextView
android:id="#+id/ticket_create_date"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="10dip"
android:layout_marginTop="2dip"
android:paddingLeft="5dip"
android:textColor="#595959"
android:textSize="10sp" />
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="center" >
<TextView
android:id="#+id/ticket_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal|center_vertical"
android:layout_margin="5dip"
android:textColor="#595959"
android:textSize="14sp" />
</LinearLayout>
</LinearLayout>
</RelativeLayout>
Hi First of all when your working with relative layout be caution because if you change an alignment or any modifications on that layout it will disappear (or) it may change the alignment , So don't worry undo your layout u can come back to your previous alignment now you can modify one by one item in the layout.
I have made a xml display with some items . But my listView of that xml is not scrolling. I have made a scrollView and the listView is inside the scrollView , is it a problem ? If I design display with keeping the listView out side the scrollView, then the lisViw is not showing on my android device display. I need such a display where need a scrollView and scrolling listview. My code is given below.
<?xml version="1.0" encoding="utf-8"?>
<merge xmlns:android="http://schemas.android.com/apk/res/android" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#FFFFFF"
android:orientation="vertical" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#drawable/head_logo" >
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<Button
android:id="#+id/cardlistButton"
android:layout_width="0dip"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="#drawable/head_menu04" />
<View
android:layout_width="1dip"
android:layout_height="fill_parent"
android:background="#ffffff" />
<Button
android:id="#+id/cameraButton"
android:layout_width="0dip"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="#drawable/head_menu02" />
<View
android:layout_width="1dip"
android:layout_height="fill_parent"
android:background="#ffffff" />
<Button
android:id="#+id/homeButton"
android:layout_width="0dip"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="#drawable/head_menu03" />
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#drawable/title_detail"
android:gravity="right|center_vertical" >
</LinearLayout>
<ScrollView
android:layout_width="fill_parent"
android:layout_height="wrap_content" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#FFFFFF"
android:gravity="center"
android:orientation="vertical" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="15dip"
android:layout_marginRight="15dip"
android:orientation="vertical"
android:paddingBottom="10dip"
android:paddingTop="15dip" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="7dip"
android:orientation="horizontal" >
<TextView
android:layout_width="80dip"
android:layout_height="wrap_content"
android:gravity="left"
android:text="STATUS :"
android:textColor="#666666"
android:textStyle="bold" />
<TextView
android:id="#+id/pdtvText1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="5dip"
android:text=""
android:textColor="#666666"
android:textStyle="bold" />
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="7dip"
android:orientation="horizontal" >
<TextView
android:layout_width="80dip"
android:layout_height="wrap_content"
android:gravity="left"
android:text="注文日 :"
android:textColor="#666666"
android:textStyle="bold" />
<TextView
android:id="#+id/pdtvText2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="5dip"
android:text=""
android:textColor="#666666"
android:textStyle="bold" />
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="7dip"
android:orientation="horizontal" >
<TextView
android:layout_width="80dip"
android:layout_height="wrap_content"
android:gravity="left"
android:text="納品日 :"
android:textColor="#666666"
android:textStyle="bold" />
<TextView
android:id="#+id/pdtvText3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="5dip"
android:text=""
android:textColor="#666666"
android:textStyle="bold" />
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="7dip"
android:orientation="horizontal" >
<TextView
android:layout_width="80dip"
android:layout_height="wrap_content"
android:gravity="left"
android:text="依頼枚数 :"
android:textColor="#666666"
android:textStyle="bold" />
<TextView
android:id="#+id/pdtvText4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="5dip"
android:text=""
android:textColor="#666666"
android:textStyle="bold" />
<TextView
android:id="#+id/pdtvText41"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="10dip"
android:text=""
android:textColor="#FF0000"
android:textStyle="bold" />
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="7dip"
android:orientation="horizontal" >
<TextView
android:layout_width="80dip"
android:layout_height="wrap_content"
android:gravity="left"
android:text="納品枚数 :"
android:textColor="#666666"
android:textStyle="bold" />
<TextView
android:id="#+id/pdtvText5"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="5dip"
android:text=""
android:textColor="#666666"
android:textStyle="bold" />
</LinearLayout>
</LinearLayout>
<LinearLayout
android:id="#+id/errorLayout"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#drawable/subtitle_error"
android:gravity="right|center_vertical" >
</LinearLayout>
<LinearLayout
android:id="#+id/bluebar"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#drawable/subtitle_deli"
android:gravity="right|center_vertical" >
</LinearLayout>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="15dip"
android:gravity="left"
android:paddingBottom="5dip"
android:paddingTop="5dip"
android:text=" "
android:textColor="#666666"
android:textStyle="bold" />
<ImageView
android:id="#+id/imageviewproduct"
android:layout_width="300dip"
android:layout_height="180dip"
android:layout_marginBottom="10dip"
android:scaleType="fitXY" />
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="11.89" >
<ListView
android:id="#+id/productlistall"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:cacheColorHint="#00000000" >
</ListView>
</LinearLayout>
</LinearLayout>
</ScrollView>
</LinearLayout>
</merge>
Never add ListView,MapView,WebView(its already scrollable) in ScrollView
Remove from ScrollView.
Do not put a ListView inside a ScrollView.
ListView already handles
scrolling, you're only going to run into trouble.
Using a ListView to make it not scroll is extremely expensive and goes against the whole purpose of ListView. You should NOT do this. Just use a LinearLayout instead.
As samir and coader said, never use them in scrollview; but let this time be an exception, first check whether you've entered enough no. of items inside the list such tat there is enough no. of objects to scroll
in android i have add two list view and add in linear layout this linear layout add in scroll but when i scroll on listview whole layout scrollable how we can scroll specific view my xml is below
android:layout_below="#+id/pvr_add">
<LinearLayout android:id="#+id/linear"
android:orientation="vertical" android:layout_width="fill_parent"
android:layout_height="wrap_content">
<ImageView android:id="#+id/lineshow" android:layout_width="fill_parent"
android:layout_height="wrap_content" android:src="#drawable/largeline"
android:layout_marginTop="3dip"
android:layout_centerHorizontal="true">
</ImageView>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/theater_details" android:layout_width="fill_parent"
android:layout_gravity="center_horizontal"
android:layout_height="50dip">
<ImageView android:id="#+id/line" android:src="#drawable/line"
android:layout_below="#+id/lineshow"
android:layout_centerInParent="true" android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<TextView android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="#+id/lineshow"
android:layout_centerInParent="true"
android:layout_toLeftOf="#+id/line"
android:paddingLeft="8dip"
android:id="#+id/movie_name" android:text="English(UA)" />
<TextView android:layout_width="wrap_content"
android:gravity="right" android:layout_height="wrap_content"
android:paddingRight="8dip"
android:layout_below="#+id/lineshow"
android:layout_alignParentRight="true"
android:layout_toRightOf="#+id/line"
android:textColor="#f8c400"
android:layout_centerInParent="true"
android:id="#+id/theater_location" />
</RelativeLayout>
<ImageView android:id="#+id/lineshow" android:layout_width="fill_parent"
android:layout_height="wrap_content" android:src="#drawable/largeline"
android:layout_marginTop="3dip"
android:layout_centerHorizontal="true">
</ImageView>
<TextView android:layout_width="fill_parent"
android:layout_gravity="center_horizontal" android:layout_height="wrap_content"
android:layout_below="#+id/theater_details" android:id="#+id/select_date_time"
android:layout_marginLeft="10dip"
android:layout_marginTop="5dip"
android:text="Select date and time" />
<TableLayout android:id="#+id/weekly_show"
android:layout_below="#+id/select_date_time"
android:layout_width="270dip" android:layout_marginTop="10dip"
android:background="#drawable/gap"
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_gravity="center_horizontal" android:stretchColumns="*"
android:layout_height="wrap_content">
</TableLayout>
<ListView android:layout_height="100dip"
android:cacheColorHint="#00000000" android:layout_gravity="center_horizontal"
android:listSelector="#drawable/list_selector_background"
android:choiceMode="multipleChoice"
android:focusable="true"
android:focusableInTouchMode="true"
android:layout_width="270dip" android:layout_below="#+id/weekly_show"
android:id="#android:id/list"></ListView>
<LinearLayout android:id="#+id/linear"
android:orientation="vertical" android:paddingTop="15dip"
android:layout_below="#android:id/list" android:layout_gravity="center_horizontal"
android:layout_width="270dip" android:layout_height="wrap_content">
<RelativeLayout android:layout_width="270dip"
android:layout_height="30dip" android:id="#+id/reserve_seat"
android:visibility="visible"
android:background="#drawable/roundedcorner">
<TextView android:layout_width="wrap_content"
android:layout_alignParentLeft="true" android:layout_height="wrap_content"
android:textSize="12dip"
android:layout_marginLeft="3dip"
android:id="#+id/seat_reqired" android:text="How many seat would you like"
android:textColor="#000000"
/>
<TextView android:layout_width="wrap_content"
android:layout_alignParentRight="true" android:layout_height="fill_parent"
android:gravity="center"
android:id="#+id/seekbarvalue" android:background="#drawable/noofseats" />
</RelativeLayout>
<SeekBar android:layout_width="270dip"
android:visibility="visible"
android:layout_height="wrap_content" android:layout_below="#+id/reserve_seat"
android:paddingTop="10dip" android:id="#+id/seekbar" android:max="10" />
<RelativeLayout android:layout_width="270dip"
android:layout_height="100dip" android:id="#+id/check_avilable_seat"
android:visibility="gone"
android:layout_marginTop="10dip" >
<ListView android:layout_height="100dip"
android:cacheColorHint="#00000000" android:layout_gravity="center_horizontal"
android:listSelector="#drawable/list_selector_background"
android:focusable="true"
android:focusableInTouchMode="true"
android:layout_width="270dip"
android:background="#drawable/roundedcorner"
android:id="#+id/list1"></ListView>
</RelativeLayout>
<Button
android:id="#+id/proceed"
android:layout_gravity="center_horizontal"
android:background="#drawable/proceed_button"
android:layout_marginTop="5dip"
android:layout_marginBottom="5dip"
android:visibility="gone"
android:layout_width="wrap_content" android:layout_height="30dip"></Button>
</LinearLayout>
</LinearLayout>
</ScrollView>
You missed the opening scrollview part of the tag...
However this question is identical to
Android ScrollView layout problem
In short: never put listview inside scrollview.