button disappears in a horizontal orientation - android

Hello I have LinearLayout in ScrollView
In this LinearLayout I have some checkbox and
button at the bottom.
In vertical view it's ok but in horizontal view
the button disappear.
You can see this situation on screen shots:
vertical view
horizontal view
Of course srclolling down doesnt help
This is my xml
<ScrollView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="80dp"
android:layout_marginLeft="10dp"
>
<CheckBox android:id="#+id/hotele"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Hotele"
android:textSize="18sp"
android:layout_margin="5dp"
android:checked="true"
/>
<!-- more checkboxs... -->
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
xmlns:android="http://schemas.android.com/apk/res/android">
<Button
android:id="#+id/gotowe"
android:layout_width="160dp"
android:layout_height="wrap_content"
android:layout_marginTop="30dp"
android:background="#color/colorPrimary"
android:padding="5dp"
android:text="Gotowe"
android:textColor="#fff"
android:textSize="16sp"
android:layout_centerInParent="true"
android:textAllCaps="false"/>
</RelativeLayout>
</LinearLayout>
</ScrollView>

Try to set the
<ScrollView
android:layout_width="fill_parent"
android:layout_height="fill_parent">
to be with layout_height="wrap_content" . This will let you scroll to the end of the content.

I'm not sure what your looking for but may this help you
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_marginTop="80dp"
android:weightSum="10">
<ScrollView
android:id="#+id/scrollView"
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_marginBottom="10dp"
android:layout_weight="9.5">
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:orientation="vertical">
<CheckBox
android:id="#+id/hotele"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="5dp"
android:checked="true"
android:text="Hotele"
android:textSize="18sp" />
</LinearLayout>
</ScrollView>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_weight=".5">
<Button
android:id="#+id/gotowe"
android:layout_width="160dp"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:layout_gravity="center"
android:background="#color/colorPrimary"
android:padding="5dp"
android:text="Gotowe"
android:textAllCaps="false"
android:textColor="#fff"
android:textSize="16sp" />
</RelativeLayout>
</LinearLayout>

<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
xmlns:android="http://schemas.android.com/apk/res/android">
<ScrollView android:layout_width="fill_parent"
android:layout_height="fill_parent>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_marginTop="80dp"
android:layout_marginLeft="10dp"
>
<CheckBox android:id="#+id/hotele"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Hotele"
android:textSize="18sp"
android:layout_margin="5dp"
android:checked="true"
/>
<!-- more checkboxs... -->
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
xmlns:android="http://schemas.android.com/apk/res/android">
</RelativeLayout>
</LinearLayout>
</ScrollView>
<Button
android:id="#+id/gotowe"
android:layout_width="160dp"
android:layout_height="wrap_content"
android:layout_marginTop="30dp"
android:background="#color/colorPrimary"
android:padding="5dp"
android:text="Gotowe"
android:textColor="#fff"
android:textSize="16sp"
android:layout_centerInParent="true"
android:textAllCaps="false"/>
</RelativeLayout>

Try this
<ScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_marginTop="80dp"
android:layout_marginLeft="10dp"
>
<CheckBox android:id="#+id/hotele"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Hotele"
android:textSize="18sp"
android:layout_margin="5dp"
android:checked="true"
/>
<!-- more checkboxs... -->
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
xmlns:android="http://schemas.android.com/apk/res/android">
<Button
android:id="#+id/gotowe"
android:layout_width="160dp"
android:layout_height="wrap_content"
android:layout_marginTop="30dp"
android:background="#color/colorPrimary"
android:padding="5dp"
android:text="Gotowe"
android:textColor="#fff"
android:textSize="16sp"
android:layout_centerInParent="true"
android:textAllCaps="false"/>
</RelativeLayout>
</LinearLayout>
</RelativeLayout>
</ScrollView>

Try this code : The list of checkbox will be scrollable and the button will be shown in two cases :
(As for the margin is up to you to choose the values of your margins)
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ScrollView
android:id="#+id/scrollable_holder"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_above="#+id/gotowe"
android:layout_marginLeft="10dp"
android:layout_marginTop="80dp"
android:isScrollContainer="true">
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<CheckBox
android:id="#+id/hotele"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="5dp"
android:checked="true"
android:text="Hotele"
android:textSize="18sp"
/>
<CheckBox
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="5dp"
android:checked="true"
android:text="Hotele"
android:textSize="18sp"
/>
<CheckBox
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="5dp"
android:checked="true"
android:text="Hotele"
android:textSize="18sp"
/>
<CheckBox
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="5dp"
android:checked="true"
android:text="Hotele"
android:textSize="18sp"
/>
<CheckBox
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="5dp"
android:checked="true"
android:text="Hotele"
android:textSize="18sp"
/>
<CheckBox
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="5dp"
android:checked="true"
android:text="Hotele"
android:textSize="18sp"
/>
<CheckBox
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="5dp"
android:checked="true"
android:text="Hotele"
android:textSize="18sp"
/>
<CheckBox
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="5dp"
android:checked="true"
android:text="Hotele"
android:textSize="18sp"
/>
<CheckBox
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="5dp"
android:checked="true"
android:text="Hotele"
android:textSize="18sp"
/>
<CheckBox
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="5dp"
android:checked="true"
android:text="Hotele"
android:textSize="18sp"
/>
<CheckBox
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="5dp"
android:checked="true"
android:text="Hotele"
android:textSize="18sp"
/>
<CheckBox
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="5dp"
android:checked="true"
android:text="Hotele"
android:textSize="18sp"
/>
<CheckBox
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="5dp"
android:checked="true"
android:text="Hotele"
android:textSize="18sp"
/>
<CheckBox
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="5dp"
android:checked="true"
android:text="Hotele"
android:textSize="18sp"
/>
<CheckBox
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="5dp"
android:checked="true"
android:text="Hotele"
android:textSize="18sp"
/>
<CheckBox
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="5dp"
android:checked="true"
android:text="Hotele"
android:textSize="18sp"
/>
<CheckBox
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="5dp"
android:checked="true"
android:text="Hotele"
android:textSize="18sp"
/>
<CheckBox
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="5dp"
android:checked="true"
android:text="Hotele"
android:textSize="18sp"
/>
<CheckBox
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="5dp"
android:checked="true"
android:text="Hotele"
android:textSize="18sp"
/>
<!-- more checkboxs... -->
</LinearLayout>
</ScrollView>
<Button
android:id="#+id/gotowe"
android:layout_width="160dp"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:layout_marginBottom="10dp"
android:layout_marginTop="30dp"
android:background="#color/colorPrimary"
android:padding="5dp"
android:text="Gotowe"
android:textAllCaps="false"
android:textColor="#fff"
android:textSize="16sp"/>
</RelativeLayout>

Just a minor change from your current xml file.
Try changing the margins of your inner Linearlayout to padding.
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:paddingTop="80dp"
android:paddingLeft="10dp"
>
I was able to make it work this way.

Related

Android custom listview vertical bar integration in an existing listview

I'm trying to integrate a vertical colored bar in front of my custom listview. I cannot succeed and I hope anyone could help me out.
The correct way without the colored bar:
The XML code of the above image:
<?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="wrap_content"
android:orientation="vertical"
android:padding="4dp" >
<TextView
android:id="#+id/subject"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textStyle="bold" />
<TextView
android:id="#+id/relation"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#color/default_green"
android:textSize="16sp"
android:textStyle="bold" />
<TextView
android:id="#+id/ticketDepartmentName"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#999999"
android:textSize="14sp"
android:textStyle="bold" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<TextView
android:id="#+id/ticketDueDate"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#drawable/color_transparent"
android:gravity="center_horizontal"
android:textColor="#color/red"
android:textStyle="bold" />
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<TextView
android:id="#+id/priority"
android:layout_width="90dp"
android:layout_height="wrap_content"
android:layout_marginRight="3dp"
android:layout_toLeftOf="#id/status"
android:background="#drawable/default_button"
android:gravity="center_horizontal"
android:textColor="#ffffff" />
<TextView
android:id="#+id/status"
android:layout_width="90dp"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:background="#drawable/salesdesk_button"
android:gravity="center_horizontal"
android:textColor="#ffffff" />
</RelativeLayout>
</LinearLayout>
</LinearLayout>
A nice try can be found here but does not work properly:
You could always add an imageview with an image of a vertical bar with the desired color inside another root LinearLayout which would be horizontal.
Try this..
<?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="wrap_content" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<TextView
android:id="#+id/colorBar"
android:layout_width="4dp"
android:layout_height="match_parent"
android:background="#478848" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<TextView
android:id="#+id/subject"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Text1"
android:textStyle="bold" />
<TextView
android:id="#+id/relation"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Text2"
android:textSize="16sp"
android:textStyle="bold" />
<TextView
android:id="#+id/ticketDepartmentName"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Text3"
android:textColor="#999999"
android:textSize="14sp"
android:textStyle="bold" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<TextView
android:id="#+id/ticketDueDate"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="0.4"
android:text="Text4"
android:textStyle="bold" />
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="0.6"
android:orientation="horizontal" >
<TextView
android:id="#+id/priority"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_weight="1"
android:background="#F89407"
android:gravity="center"
android:text="priority"
android:textColor="#ffffff" />
<TextView
android:id="#+id/status"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_weight="1"
android:background="#478948"
android:gravity="center"
android:text="status"
android:textColor="#ffffff" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
</LinearLayout>
</LinearLayout>

Android custom listview adapter vertical color bar

I'm trying to integrate a color bar like example below in my XML file which is currently working properply only integrating this colored vertical bar is making it difficult.
My custom listview adapterview which works without any color bar
<?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="wrap_content"
android:orientation="vertical"
android:padding="4dp" >
<TextView
android:id="#+id/subject"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textStyle="bold" />
<TextView
android:id="#+id/relation"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#color/default_green"
android:textSize="16sp"
android:textStyle="bold" />
<TextView
android:id="#+id/ticketDepartmentName"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#999999"
android:textSize="14sp"
android:textStyle="bold" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<TextView
android:id="#+id/ticketDueDate"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#drawable/color_transparent"
android:gravity="center_horizontal"
android:textColor="#color/red"
android:textStyle="bold" />
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<TextView
android:id="#+id/priority"
android:layout_width="90dp"
android:layout_height="wrap_content"
android:layout_marginRight="3dp"
android:layout_toLeftOf="#id/status"
android:background="#drawable/default_button"
android:gravity="center_horizontal"
android:textColor="#ffffff" />
<TextView
android:id="#+id/status"
android:layout_width="90dp"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:background="#drawable/salesdesk_button"
android:gravity="center_horizontal"
android:textColor="#ffffff" />
</RelativeLayout>
</LinearLayout>
</LinearLayout>
I succeeded for let us say 50% to make it work with a textview but it's not how it should be. Here the code I got after a while.
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical" >
<TextView
android:id="#+id/colorBar"
android:layout_width="4dp"
android:layout_height="match_parent"
android:layout_alignParentLeft="true"
android:background="#drawable/default_button" />
<TextView
android:id="#+id/subject"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toRightOf="#id/colorBar"
android:textStyle="bold" />
<TextView
android:id="#+id/relation"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#id/subject"
android:layout_toRightOf="#id/colorBar"
android:textColor="#color/default_green"
android:textSize="16sp"
android:textStyle="bold" />
<TextView
android:id="#+id/ticketDepartmentName"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#id/relation"
android:layout_toRightOf="#id/colorBar"
android:textColor="#999999"
android:textSize="14sp"
android:textStyle="bold" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<TextView
android:id="#+id/ticketDueDate"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#drawable/color_transparent"
android:gravity="center_horizontal"
android:textColor="#color/red"
android:textStyle="bold" />
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<TextView
android:id="#+id/priority"
android:layout_width="90dp"
android:layout_height="wrap_content"
android:layout_marginRight="3dp"
android:layout_toLeftOf="#id/status"
android:background="#drawable/default_button"
android:gravity="center_horizontal"
android:textColor="#ffffff" />
<TextView
android:id="#+id/status"
android:layout_width="90dp"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:background="#drawable/default_button"
android:gravity="center_horizontal"
android:textColor="#ffffff" />
</RelativeLayout>
</LinearLayout>
</RelativeLayout>
This looks like so As you can see the colored bar stops in the middle I have no idea why and my last Relative and Linearlayout get messed up. Please help, thanks in advance!
Try this..
<?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="wrap_content" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<TextView
android:id="#+id/colorBar"
android:layout_width="4dp"
android:layout_height="match_parent"
android:background="#478848" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<TextView
android:id="#+id/subject"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Text1"
android:textStyle="bold" />
<TextView
android:id="#+id/relation"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Text2"
android:textSize="16sp"
android:textStyle="bold" />
<TextView
android:id="#+id/ticketDepartmentName"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Text3"
android:textColor="#999999"
android:textSize="14sp"
android:textStyle="bold" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<TextView
android:id="#+id/ticketDueDate"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="0.4"
android:text="Text4"
android:textStyle="bold" />
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="0.6"
android:orientation="horizontal" >
<TextView
android:id="#+id/priority"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_weight="1"
android:background="#F89407"
android:gravity="center"
android:text="priority"
android:textColor="#ffffff" />
<TextView
android:id="#+id/status"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_weight="1"
android:background="#478948"
android:gravity="center"
android:text="status"
android:textColor="#ffffff" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
</LinearLayout>
</LinearLayout>

ScrollView not accepting multiple child

Hello I need to set scroll view in following code,and set after first relative layout but it gives me :
main.xml: IllegalStateException: ScrollView can host only one direct child
that means i cant use scrollview in multiple layout child.So how can i use scroll view inside first relative layout and cover with all inner relative layout.
Code:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:background="#drawable/page1_11"
android:layout_height="fill_parent">
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/login_rellay_01" android:layout_width="match_parent"
android:layout_height="wrap_content">
<ImageView android:layout_height="wrap_content"
android:layout_width="match_parent" android:src="#drawable/page1_1"
android:id="#+id/imageView1" android:layout_alignParentLeft="true" />
<TextView android:layout_height="wrap_content"
android:layout_width="wrap_content" android:text="Shanesh COLORS App"
android:textSize="13dp" android:textStyle="bold" android:textColor="#49515F"
android:layout_centerInParent="true" />
</RelativeLayout>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_below="#+id/login_rellay_01" android:id="#+id/login_rellay_02"
android:layout_width="fill_parent" android:layout_height="wrap_content">
<ImageView android:layout_height="wrap_content"
android:layout_width="wrap_content" android:src="#drawable/page1_4"
android:id="#+id/imageView1" android:layout_centerHorizontal="true" />
<TextView android:layout_height="wrap_content"
android:layout_width="wrap_content" android:text="SIGN IN"
android:textSize="13dp" android:textStyle="bold" android:textColor="#FFFFFF"
android:layout_centerInParent="true" />
<Button android:layout_height="wrap_content"
android:layout_width="wrap_content" android:background="#drawable/page1_2"
android:layout_centerVertical="true" android:layout_marginLeft="10dp" />
<Button android:layout_height="wrap_content"
android:layout_width="wrap_content" android:background="#drawable/page1_3"
android:layout_centerVertical="true" android:layout_marginRight="10dp"
android:layout_alignParentRight="true" />
</RelativeLayout>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/login_rellay_03" android:layout_below="#+id/login_rellay_02"
android:layout_width="match_parent" android:layout_height="wrap_content">
<ImageView android:layout_height="wrap_content"
android:layout_width="match_parent" android:src="#drawable/page1_5"
android:id="#+id/imgv_page1_5" android:layout_alignParentLeft="true" />
<!-- <ImageView android:layout_height="wrap_content" android:layout_below="#+id/imgv_page1_5"
android:layout_marginTop="1dp" android:layout_width="match_parent" android:src="#drawable/page1_6"
android:id="#+id/imgv_page1_6" android:layout_alignParentLeft="true" /> -->
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/login_rellay_03" android:layout_centerInParent="true"
android:layout_below="#+id/login_rellay_02" android:layout_width="wrap_content"
android:layout_height="wrap_content">
<TextView android:layout_height="wrap_content"
android:layout_width="wrap_content" android:text="SIGN IN "
android:textSize="13dp" android:id="#+id/login_txvx_dwbnr_1"
android:textStyle="bold" android:textColor="#000000"
android:layout_marginLeft="10dp" android:layout_centerVertical="true" />
<TextView android:layout_height="wrap_content"
android:layout_width="wrap_content" android:text="with your "
android:id="#+id/login_txvx_dwbnr_2" android:layout_toRightOf="#+id/login_txvx_dwbnr_1"
android:textSize="13dp" android:layout_centerVertical="true"
android:textColor="#000000" />
<TextView android:layout_height="wrap_content"
android:layout_width="wrap_content" android:text="Shanesh Colors"
android:id="#+id/login_txvx_dwbnr_3" android:layout_toRightOf="#+id/login_txvx_dwbnr_2"
android:textSize="13dp" android:textStyle="bold"
android:layout_centerVertical="true" android:textColor="#000000" />
<TextView android:layout_height="wrap_content"
android:layout_width="wrap_content" android:text=" App Account "
android:id="#+id/login_txvx_dwbnr_4" android:layout_toRightOf="#+id/login_txvx_dwbnr_3"
android:textSize="13dp" android:layout_centerVertical="true"
android:textColor="#000000" />
</RelativeLayout>
</RelativeLayout>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/login_rellay_04" android:layout_marginTop="1dp"
android:gravity="center" android:layout_below="#+id/login_rellay_03"
android:layout_width="match_parent" android:layout_height="wrap_content">
<ImageView android:layout_height="180dp"
android:layout_width="306dp" android:background="#FFFFFF" android:id="#+id/imgv_page1_6"
android:layout_centerInParent="true" />
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/login_rellay_04" android:layout_width="match_parent"
android:layout_height="wrap_content" android:gravity="center">
<TextView android:layout_height="wrap_content"
android:layout_width="wrap_content" android:text="User Name:"
android:id="#+id/login_txvx_dwbnr_5" android:layout_toRightOf="#+id/login_txvx_dwbnr_1"
android:textSize="11dp" android:layout_centerVertical="true"
android:textColor="#49515F" />
<EditText android:layout_height="40dp" android:layout_width="220dp"
android:layout_marginTop="10dp" android:layout_toRightOf="#+id/login_txvx_dwbnr_5" />
</RelativeLayout>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/login_rellay_05" android:layout_width="match_parent"
android:layout_height="wrap_content" android:gravity="center"
android:layout_below="#+id/login_rellay_04">
<TextView android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:text=" Password:"
android:id="#+id/login_txvx_dwbnr_5"
android:layout_toRightOf="#+id/login_txvx_dwbnr_1"
android:textSize="11dp"
android:layout_centerVertical="true"
android:textColor="#49515F" />
<EditText android:layout_height="40dp" android:layout_width="220dp"
android:layout_alignParentTop="true" android:layout_marginTop="10dp"
android:layout_toRightOf="#+id/login_txvx_dwbnr_5" />
</RelativeLayout>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/login_rellay_06"
android:layout_marginTop="3dp"
android:layout_height="wrap_content"
android:gravity="center"
android:layout_below="#+id/login_rellay_05"
android:layout_width="match_parent">
<TextView android:layout_height="wrap_content"
android:textColor="#000000"
android:text="No Account?"
android:textStyle="bold"
android:textSize="11dp"
android:id="#+id/login_txvx_dwbnr_9"
android:layout_width="wrap_content"/>
<TextView android:text="Sign Up"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:id="#+id/login_txvx_signup_account"
android:textColor="#8891A2"
android:textStyle="bold"
android:layout_toRightOf="#+id/login_txvx_dwbnr_9"
android:textSize="11dp"
/></RelativeLayout>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/login_rellay_07"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:layout_below="#+id/login_rellay_06"
android:layout_width="match_parent">
<CheckBox android:layout_height="wrap_content"
android:id="#+id/checkBox1"
android:layout_below="#+id/login_txvx_signup_account"
android:layout_width="wrap_content"
android:textColor="#49515F"
android:textSize="11dp"
android:layout_marginLeft="10dp"
android:text=" Remember User Name and Password?"
/>
</RelativeLayout>
</RelativeLayout>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/login_rellay_08"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:layout_marginTop="60dp"
android:layout_below="#+id/login_rellay_04"
android:layout_width="match_parent">
<ImageView android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:src="#drawable/page1_8"
/>
</RelativeLayout>
</RelativeLayout>
You make the outer most element the scrollview, which will give only one child your top-level relativelayout.

How to scroll in android LinearLayout?

Hi i have an application, where i want to use scroll option in liner layout. Please help me i am stuck.
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content" android:layout_height="fill_parent"
android:orientation="vertical"
android:scrollbars="vertical"
android:scrollbarAlwaysDrawVerticalTrack="true"
>
<AnalogClock android:id="#+id/clock1" android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<ImageButton android:id="#+id/rssbtn" android:src="#drawable/rss"
android:layout_width="wrap_content" android:layout_height="wrap_content" />
<ProgressBar android:id="#+id/progress"
android:layout_width="wrap_content" android:layout_height="wrap_content" />
<RadioGroup android:id="#+id/widget1" android:layout_width="wrap_content"
android:layout_height="wrap_content" xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical">
<RadioButton android:id="#+id/widget2"
android:layout_width="wrap_content" android:layout_height="wrap_content"
android:text="Plain" android:checked="false" android:layout_gravity="left"
android:layout_weight="0">
</RadioButton>
<RadioButton android:id="#+id/widget3"
android:layout_width="wrap_content" android:layout_height="wrap_content"
android:text="Serif" android:checked="true" android:layout_gravity="left"
android:layout_weight="0" android:typeface="serif">
</RadioButton>
<RadioButton android:id="#+id/widget25"
android:layout_width="wrap_content" android:layout_height="wrap_content"
android:text="Bold" android:checked="false" android:layout_weight="0"
android:layout_gravity="left" android:textStyle="bold">
</RadioButton>
</RadioGroup>
<Spinner android:id="#+id/widget1" android:layout_width="fill_parent"
android:layout_height="wrap_content" android:drawSelectorOnTop="false" />
<TimePicker android:id="#+id/widget3" android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<CheckBox android:id="#+id/plain_cb" android:text="Plain"
android:layout_width="wrap_content" android:layout_height="wrap_content" />
<CheckBox android:id="#+id/serif_cb" android:text="Serif"
android:layout_width="wrap_content" android:layout_height="wrap_content"
android:typeface="serif" />
<CheckBox android:id="#+id/bold_cb" android:text="Bold"
android:layout_width="wrap_content" android:layout_height="wrap_content"
android:textStyle="bold" />
<CheckBox android:id="#+id/italic_cb" android:text="Italic"
android:layout_width="wrap_content" android:layout_height="wrap_content"
android:textStyle="italic" />
<Button android:id="#+id/button1" android:text="Label"
android:layout_width="fill_parent" android:layout_height="fill_parent" />
<Button android:id="#+id/button2" android:text="Label"
android:layout_width="fill_parent" android:layout_height="fill_parent"
android:typeface="serif" />
<Button android:id="#+id/button3" android:text="Label"
android:layout_width="fill_parent" android:layout_height="fill_parent"
android:textStyle="italic" />
<DatePicker android:id="#+id/datepicker"
android:layout_width="wrap_content" android:layout_height="wrap_content" />
<EditText android:id="#+id/edittext1" android:text="EditText 1"
android:layout_width="wrap_content" android:layout_height="wrap_content" />
<EditText android:id="#+id/button2" android:text="(206)555-1212"
android:layout_width="wrap_content" android:layout_height="wrap_content"
android:typeface="serif" android:phoneNumber="true" />
<EditText android:id="#+id/password" android:text="SuperSecret"
android:layout_width="wrap_content" android:layout_height="wrap_content"
android:textStyle="bold" android:password="true" />
</LinearLayout>
Wrap your LinearLayout in a ScrollView at the top of the file
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content" android:layout_height="fill_parent">
<LinearLayout
android:layout_width="wrap_content" android:layout_height="fill_parent"
android:orientation="vertical"
android:scrollbars="vertical"
android:scrollbarAlwaysDrawVerticalTrack="true"
>
.....
</LinearLayout>
</ScrollView>

Again ImageButton issues

Thanks at all for all your help for now.I have another little issues
This is a portion of my layout which give me some problems:
<RelativeLayout android:id="#+id/card_address_layout"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:visibility="visible"
>
<TextView
style="#style/card_field"
android:id="#+id/card_indirizzo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:layout_gravity="left|center_vertical"
android:layout_marginTop="8dp"
android:maxLength="35"
android:ellipsize="marquee"
/>
<ImageButton
android:id="#+id/card_address_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="right|center_vertical"
android:layout_toRightOf="#id/card_indirizzo"
android:src="#drawable/map_selector"
android:onClick="startMap"
android:padding="0dp" />
</RelativeLayout>
The image button src is a selector, in this case this one:
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_pressed="true" android:drawable="#drawable/map_b" /> <!-- pressed -->
<item android:drawable="#drawable/map_a" /> <!-- default -->
This is the result and I really don't understand why, why the image button has padding??!!!
Help meeeee!
This is the FULL xml:
<?xml version="1.0" encoding="utf-8"?>
<HorizontalScrollView android:id="#+id/card_images_horizontalscroll"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:scrollbars="none"
android:visibility="invisible"
>
<LinearLayout android:id="#+id/card_images_layout"
android:orientation="horizontal"
android:layout_width="wrap_content"
android:layout_height="80dp"
android:layout_marginRight="4dp"
>
</LinearLayout>
</HorizontalScrollView>
<TextView
android:id="#+id/card_images_footer"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:singleLine="true"
android:background="#drawable/click_it"
/>
<ScrollView android:id="#+id/card_data_verticalscroll"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
>
<LinearLayout android:id="#+id/main_vertical_scroll_layout"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
>
<TextView
style="#style/card_title"
android:id="#+id/card_name"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:singleLine="true"
android:layout_weight="1"
/>
<TextView
style="#style/card_category"
android:id="#+id/card_categoria"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:singleLine="true"
android:layout_marginBottom="30dp"
/>
<RelativeLayout android:id="#+id/card_address_layout"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:visibility="visible"
>
<TextView
style="#style/card_field"
android:id="#+id/card_indirizzo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:layout_gravity="left|center_vertical"
android:layout_marginTop="8dp"
android:maxLength="35"
android:ellipsize="marquee"
/>
<ImageButton
android:id="#+id/card_address_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="right|center_vertical"
android:layout_toRightOf="#id/card_indirizzo"
android:src="#drawable/map_selector"
android:onClick="startMap"
android:padding="0dp" />
</RelativeLayout>
<RelativeLayout android:id="#+id/card_phone_layout"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:visibility="gone"
>
<TextView
style="#style/card_field"
android:id="#+id/card_telefono"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:maxLength="35"
android:ellipsize="marquee"
android:layout_gravity="center_vertical"
android:layout_marginTop="8dp"
/>
<ImageButton android:text="call"
android:id="#+id/card_telefono_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_gravity="right|center_vertical"
android:src="#drawable/call_selector"
android:onClick="startCall"
/>
</RelativeLayout>
<RelativeLayout android:id="#+id/card_mail_layout"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:visibility="gone"
>
<TextView
style="#style/card_field"
android:id="#+id/card_mail"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:maxLength="35"
android:ellipsize="marquee"
android:layout_gravity="center_vertical"
android:layout_marginTop="8dp"
/>
<ImageButton android:text="mail"
android:id="#+id/card_mail_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_gravity="right|center_vertical"
android:onClick="startMailClient"
android:src="#drawable/mail_selector"
/>
</RelativeLayout>
<RelativeLayout android:id="#+id/card_www_layout"
android:orientation="horizontal"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:visibility="gone"
>
<TextView
style="#style/card_field"
android:id="#+id/card_www"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:maxLength="35"
android:ellipsize="marquee"
android:layout_gravity="center_vertical"
android:layout_marginTop="8dp"
/>
<ImageButton android:text="www"
android:id="#+id/card_www_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_gravity="right|center_vertical"
android:onClick="startDefaultBrowser"
android:src="#drawable/www_selector"
/>
</RelativeLayout>
<TextView
style="#style/card_description"
android:id="#+id/card_descrizione"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:singleLine="false"
android:layout_marginTop="30dp"
/>
</LinearLayout>
</ScrollView>
pedro , just change android:src="#drawable/map_selector" to android:background="#drawable/map_selector"
& you are done!

Categories

Resources