Not able to align the button and textView in xml - android

I have a problem in aligning an button and textView. I already have an textView and button in xml and i want another set of those, just below them.
But i am not able to add it. Please have a look at it.
Here is the xml,
<?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="match_parent"
android:animateLayoutChanges="true"
android:background="#FFFFFF">
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal|top">
<com.aavishkaar.quikies.widget.TypedfacedTextViewxmlns:your_namespace="http://schemas.android.com/apk/res/com.aavishkaar.quickies"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="Click Here"
android:id="#+id/textView"
android:layout_weight="0.6"
android:textSize="24sp"
android:textColor="#android:color/black"
android:gravity="center|left"
android:layout_marginLeft="15dp"
your_namespace:typeface="Roboto-Regular.ttf" />
<Button style="?android:attr/buttonStyleSmall"
android:id="#+id/blue0"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:text="OFF"
android:layout_weight="0.2"
android:layout_gravity="center_vertical"
android:layout_marginTop="10dp"
android:layout_marginBottom="10dp"
android:background="#drawable/switch_bg_holo_light" />
<Button style="?android:attr/buttonStyleSmall"
android:id="#+id/blue1"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:text="ON"
android:layout_weight="0.2"
android:layout_marginTop="10dp"
android:layout_marginBottom="10dp"
android:layout_marginRight="5dp"
android:background="#drawable/switch_thumb_activated_holo_light"/>
</LinearLayout>
</LinearLayout>

Try this code just change orientation in your first linear layout by default linear layout orientation is horizontal
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:animateLayoutChanges="true"
android:background="#FFFFFF"
android:orientation="vertical">
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal|top">
<com.aavishkaar.quikies.widget.TypedfacedTextView
xmlns:your_namespace="http://schemas.android.com/apk/res/com.aavishkaar.quickies"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="Click Here"
android:id="#+id/textView"
android:layout_weight="0.6"
android:textSize="24sp"
android:textColor="#android:color/black"
android:gravity="center|left"
android:layout_marginLeft="15dp"
your_namespace:typeface="Roboto-Regular.ttf"
/>
<Button
style="?android:attr/buttonStyleSmall"
android:id="#+id/blue0"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:text="OFF"
android:layout_weight="0.2"
android:layout_gravity="center_vertical"
android:layout_marginTop="10dp"
android:layout_marginBottom="10dp"
android:background="#drawable/switch_bg_holo_light"
/>
<Button
style="?android:attr/buttonStyleSmall"
android:id="#+id/blue1"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:text="ON"
android:layout_weight="0.2"
android:layout_marginTop="10dp"
android:layout_marginBottom="10dp"
android:layout_marginRight="5dp"
android:background="#drawable/switch_thumb_activated_holo_light"
/>
</LinearLayout>
<com.aavishkaar.quikies.widget.TypedfacedTextView
xmlns:your_namespace="http://schemas.android.com/apk/res/com.aavishkaar.quickies"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="Click Here"
android:id="#+id/textView"
android:layout_weight="0.6"
android:textSize="24sp"
android:textColor="#android:color/black"
android:gravity="center|left"
android:layout_marginLeft="15dp"
your_namespace:typeface="Roboto-Regular.ttf"
/>
<Button
style="?android:attr/buttonStyleSmall"
android:id="#+id/blue0"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:text="OFF"
android:layout_weight="0.2"
android:layout_gravity="center_vertical"
android:layout_marginTop="10dp"
android:layout_marginBottom="10dp"
android:background="#drawable/switch_bg_holo_light"
/>
<Button
style="?android:attr/buttonStyleSmall"
android:id="#+id/blue1"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:text="ON"
android:layout_weight="0.2"
android:layout_marginTop="10dp"
android:layout_marginBottom="10dp"
android:layout_marginRight="5dp"
android:background="#drawable/switch_thumb_activated_holo_light"
/>
</LinearLayout>
</LinearLayout>

Add
android:orientation="vertical" in first Linear Layour.
Add
android:orientation="horizontal" in Second Linear Layour.
I hope this will work , if not ignore this answer .
I'm Not very Good at this.

Related

Binding of two TextViews on vertical

There is a RelativeLayout with a nested LinearLayout that contains two TextViews positioned horizontally relative to each other. This is DiscountAmount and AmountWithDiscount.
I need to keep the DiscountAmount and AmountWithDiscount always at the same level vertically, for this I put the android property in LinearLayout: android:layout_below = "# + id / textViewRowQuantity". But if the Name is too long and takes three lines, then it will go to DiscountAmount. If Name takes no more than 2 lines, then all is well.
Tell me, please, how can I solve this problem?
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/relativeLayoutSaleListRow"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginBottom="2dp"
android:orientation="horizontal"
android:padding="5dp" >
<ImageView
android:id="#+id/imageViewRemoveRowSale"
android:layout_width="#dimen/size_30px"
android:layout_height="#dimen/size_30px"
android:layout_alignParentLeft="true"
android:layout_marginRight="10dp"
android:layout_marginTop="10dp"
android:src="#drawable/ic_action_remove"/>
<RelativeLayout
android:id="#+id/relativeLayoutIncQuantity"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="10dp"
android:layout_toRightOf="#+id/imageViewRemoveRowSale"
android:layout_toLeftOf="#+id/imageViewEditRowSale"
android:orientation="horizontal">
<TextView
android:id="#+id/textViewRowPrice"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_marginRight="5dp"
android:text="TextView" />
<TextView
android:id="#+id/textViewRowQuantity"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/textViewRowPrice"
android:layout_alignParentRight="true"
android:layout_marginRight="5dp"
android:text="TextView" />
<TextView
android:id="#+id/textViewRowName"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_toLeftOf="#+id/textViewRowPrice"
android:text="TextView" />
<LinearLayout
android:id="#+id/layoutDiscount"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/textViewRowQuantity"
android:orientation="horizontal">
<TextView
android:id="#+id/textViewRowDiscountAmount"
android:layout_width="wrap_content"
android:layout_weight="1"
android:layout_height="wrap_content"
android:layout_marginRight="5dp"
android:text="TextView" />
<TextView
android:id="#+id/textViewRowAmountWithDiscount"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="right"
android:layout_weight="1"
android:layout_marginRight="5dp"
android:text="TextView" />
</LinearLayout>
</RelativeLayout>
<ImageView
android:id="#+id/imageViewEditRowSale"
android:layout_width="#dimen/size_45px"
android:layout_height="#dimen/size_45px"
android:layout_marginTop="5dp"
android:layout_alignParentRight="true"
android:src="#drawable/ic_action_edit" />
Add result:
Implemented through ConstraintLayout. Thanks to all.
You can limit the number of lines in the TextView to 2 by adding this lines:
android:ellipsize="end"
android:lines="2"
End ellipsize end means if the text is so long then it will be replaced with three dots ...
if you want to show AmountWithDiscount is below to discount then change liner layout orientation like below .
android:orientation="vertical"
Try this :
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/relativeLayoutSaleListRow"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginBottom="2dp"
android:orientation="horizontal"
android:padding="5dp" >
<ImageView
android:id="#+id/imageViewRemoveRowSale"
android:layout_width="#dimen/size_30px"
android:layout_height="#dimen/size_30px"
android:layout_alignParentLeft="true"
android:layout_marginRight="10dp"
android:layout_marginTop="10dp"
android:src="#drawable/ic_action_remove"/>
<RelativeLayout
android:id="#+id/relativeLayoutIncQuantity"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="10dp"
android:layout_toRightOf="#+id/imageViewRemoveRowSale"
android:layout_toLeftOf="#+id/imageViewEditRowSale"
android:orientation="horizontal">
<TextView
android:id="#+id/textViewRowPrice"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_marginRight="5dp"
android:text="TextView" />
<TextView
android:id="#+id/textViewRowQuantity"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/textViewRowPrice"
android:layout_alignParentRight="true"
android:layout_marginRight="5dp"
android:text="TextView" />
<TextView
android:id="#+id/textViewRowName"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_toLeftOf="#+id/textViewRowPrice"
android:text="text"
android:minLines="2"/>
<LinearLayout
android:id="#+id/layoutDiscount"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/textViewRowName"
android:orientation="horizontal">
<TextView
android:id="#+id/textViewRowDiscountAmount"
android:layout_width="wrap_content"
android:layout_weight="1"
android:layout_height="wrap_content"
android:layout_marginRight="5dp"
android:text="TextView" />
<TextView
android:id="#+id/textViewRowAmountWithDiscount"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="right"
android:layout_weight="1"
android:layout_marginRight="5dp"
android:text="TextView" />
</LinearLayout>
</RelativeLayout>
<ImageView
android:id="#+id/imageViewEditRowSale"
android:layout_width="#dimen/size_45px"
android:layout_height="#dimen/size_45px"
android:layout_marginTop="5dp"
android:layout_alignParentRight="true"
android:src="#drawable/ic_action_edit" />
</RelativeLayout>
Hope this helps
make some change in liner layout..
<LinearLayout
android:id="#+id/layoutDiscount"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/textViewRowQuantity"
android:orientation="horizontal"
android:weightSum="1"
>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="0.3">
<TextView
android:id="#+id/textViewRowDiscountAmount"
android:layout_width="wrap_content"
android:layout_weight="1"
android:layout_height="wrap_content"
android:layout_marginRight="5dp"
android:singleLine="true"
android:text="TextViewsdfsdfdsgfd" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="0.7">
<TextView
android:id="#+id/textViewRowAmountWithDiscount"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="right"
android:layout_marginLeft="10dp"
android:layout_weight="1"
android:singleLine="true"
android:layout_marginRight="5dp"
android:text="textview" />
</LinearLayout>
</LinearLayout>
You can try out this below code
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/relativeLayoutSaleListRow"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginBottom="2dp"
android:orientation="horizontal"
android:padding="5dp" >
<ImageView
android:id="#+id/imageViewRemoveRowSale"
android:layout_width="#dimen/size_30px"
android:layout_height="#dimen/size_30px"
android:layout_alignParentLeft="true"
android:layout_marginRight="10dp"
android:layout_marginTop="10dp"
android:src="#drawable/ic_action_remove"/>
<RelativeLayout
android:id="#+id/relativeLayoutIncQuantity"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="10dp"
android:layout_toRightOf="#+id/imageViewRemoveRowSale"
android:layout_toLeftOf="#+id/imageViewEditRowSale"
android:orientation="horizontal">
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/rr_layout">
<TextView
android:id="#+id/textViewRowPrice"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_marginRight="5dp"
android:text="TextView" />
<TextView
android:id="#+id/textViewRowQuantity"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/textViewRowPrice"
android:layout_alignParentRight="true"
android:layout_marginRight="5dp"
android:text="TextView" />
<TextView
android:id="#+id/textViewRowName"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_toLeftOf="#+id/textViewRowPrice"
android:text="TextView" />
</RelativeLayout>
<LinearLayout
android:id="#+id/layoutDiscount"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/rr_layout"
android:orientation="horizontal">
<TextView
android:id="#+id/textViewRowDiscountAmount"
android:layout_width="wrap_content"
android:layout_weight="1"
android:layout_height="wrap_content"
android:layout_marginRight="5dp"
android:text="TextView" />
<TextView
android:id="#+id/textViewRowAmountWithDiscount"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="right"
android:layout_weight="1"
android:layout_marginRight="5dp"
android:text="TextView" />
</LinearLayout>
</RelativeLayout>
<ImageView
android:id="#+id/imageViewEditRowSale"
android:layout_width="#dimen/size_45px"
android:layout_height="#dimen/size_45px"
android:layout_marginTop="5dp"
android:layout_alignParentRight="true"
android:src="#drawable/ic_action_edit" /></RelativeLayout>

Two button one close to other at the bottom of RelativeLayout - Android

I am facing a problem with android layout.
I have a relative layout with a textview and an image overlapped and I would like to add two button at the bottom of the view, one close to other and that fill all the width of the view. Here below the manifest.xml
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout
android:orientation="vertical"
android:id="#+id/RecordAccelDataLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:android="http://schemas.android.com/apk/res/android">
<ImageView
android:layout_gravity="center"
android:longClickable="false"
android:layout_width="283dp"
android:layout_height="418dp"
android:src="#mipmap/bg_thand"
android:adjustViewBounds="false"
android:alpha="0.1" />
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#drawable/rectangle">
<TextView
android:textSize="20sp"
android:gravity="center_horizontal"
android:id="#+id/rec_progress_text"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="30dp"
android:text="#string/title_activity_record_accel_data"
/>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent" >
<com.adrenergic.tremorsense.circleGraph
android:layout_gravity="center"
android:id="#+id/progressgraph"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"/>
<TextView
android:textSize="20sp"
android:id="#+id/accelText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/recording"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:textIsSelectable="true"
/>
<Button
android:textColor="#ffffff"
android:layout_width="100dp"
android:id="#+id/back"
android:layout_height="50dp"
android:text="#string/back"
android:layout_gravity="center"
android:layout_marginBottom="3dip"
android:onClick="goBack"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true" />
<Button
android:textColor="#ffffff"
android:layout_width="100dp"
android:layout_height="50dp"
android:layout_gravity="center"
android:text="#string/stats"
android:onClick="goBack"
android:id="#+id/stats"
android:layout_marginBottom="3dip"
android:layout_centerHorizontal="true"
android:layout_alignParentBottom="true"
android:layout_toRightOf="#+id/back"/>
</RelativeLayout>
</LinearLayout>
</FrameLayout>
The layout appears in this way.
I would like that the two button appear in the same position but centered and that they fill equally the view in width.
Hope you will help me.
Can u modify your button layout impl. with the below sample and try.
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:weightSum="1">
<Button
android:textColor="#ffffff"
android:layout_width="0dp"
android:id="#+id/back"
android:layout_weight="0.5"
android:layout_height="50dp"
android:text="#string/back"
android:layout_gravity="center"
android:layout_marginBottom="3dip"
android:onClick="goBack"/>
<Button
android:textColor="#ffffff"
android:layout_width="0dp"
android:layout_height="50dp"
android:layout_weight="0.5"
android:layout_gravity="center"
android:text="#string/stats"
android:onClick="goBack"
android:id="#+id/stats"
android:layout_marginBottom="3dip"/>
</LinearLayout>
Hi you can put buttons in linear layout and align parent bottom:
<?xml version="1.0" encoding="utf-8"?>
<ImageView
android:layout_width="283dp"
android:layout_height="418dp"
android:layout_gravity="center"
android:adjustViewBounds="false"
android:alpha="0.1"
android:longClickable="false"
android:src="#mipmap/bg_thand" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#drawable/rectangle"
android:orientation="vertical">
<TextView
android:id="#+id/rec_progress_text"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="30dp"
android:gravity="center_horizontal"
android:text="#string/title_activity_record_accel_data"
android:textSize="20sp" />
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<com.adrenergic.tremorsense.circleGraph
android:id="#+id/progressgraph"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:layout_gravity="center" />
<TextView
android:id="#+id/accelText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:text="#string/recording"
android:textIsSelectable="true"
android:textSize="20sp" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:orientation="horizontal">
<Button
android:id="#+id/back"
android:layout_width="0dp"
android:layout_height="50dp"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:layout_gravity="center"
android:layout_marginBottom="3dip"
android:layout_weight="1"
android:onClick="goBack"
android:text="#string/back"
android:textColor="#ffffff" />
<Button
android:id="#+id/stats"
android:layout_width="0dp"
android:layout_height="50dp"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:layout_gravity="center"
android:layout_marginBottom="3dip"
android:layout_toRightOf="#+id/back"
android:layout_weight="1"
android:onClick="goBack"
android:text="#string/stats"
android:textColor="#ffffff" />
</LinearLayout>
</RelativeLayout>
</LinearLayout>
check this it will help.
android:weight is what you may be looking for. Enclose the two buttons inside a linear layout and add android:weight =1 for both of them. An example would be :
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
>
<Button android:id="#+id/button1"
...
android:layout_weight="1"/>
<View
android:id="#+id/space"
...
android:layout_weight=".1"/>
<Button android:id="#+id/button2"
...
android:layout_weight="1"/>
</LinearLayout>
You need to add spacer in in center bottom and align two button to that spacer like this :
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent" >
<com.adrenergic.tremorsense.circleGraph
android:layout_gravity="center"
android:id="#+id/progressgraph"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"/>
<TextView
android:textSize="20sp"
android:id="#+id/accelText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:textIsSelectable="true"
/>
//Aligh Space in center with align to bottom
and set relation of two button to this spacer
<Space
android:layout_width="1px"
android:layout_height="1px"
android:layout_above="#+id/back"
android:layout_centerHorizontal="true"
android:layout_alignParentBottom="true"
android:id="#+id/space"/>
<Button
android:textColor="#ffffff"
android:layout_width="100dp"
android:id="#+id/back"
android:layout_height="50dp"
android:text="Back"
android:layout_gravity="center"
android:onClick="goBack"
android:layout_alignParentBottom="true"
android:layout_alignStart="#+id/accelText"/>
<Button
android:textColor="#ffffff"
android:layout_width="100dp"
android:layout_height="50dp"
android:layout_gravity="center"
android:text="Status"
android:onClick="goBack"
android:id="#+id/stats"
android:layout_alignParentBottom="true"
android:layout_toStartOf="#+id/space"/>
</RelativeLayout>
Use this layout changes made with Button added inside Linear Layout and filled it with weight with android:gravity="bottom" and android:orientation="horizontal".
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/RecordAccelDataLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<ImageView
android:layout_width="283dp"
android:layout_height="418dp"
android:layout_gravity="center"
android:adjustViewBounds="false"
android:alpha="0.1"
android:longClickable="false"
android:src="#drawable/common_ic_googleplayservices" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#drawable/common_ic_googleplayservices"
android:orientation="vertical">
<TextView
android:id="#+id/rec_progress_text"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="30dp"
android:gravity="center_horizontal"
android:text="Progress"
android:textSize="20sp" />
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<com.adrenergic.tremorsense.circleGraph
android:id="#+id/progressgraph"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:layout_gravity="center" />
<TextView
android:id="#+id/accelText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:text="REcording"
android:textIsSelectable="true"
android:textSize="20sp" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="bottom"
android:orientation="horizontal"
android:weightSum="1">
<Button
android:id="#+id/back"
android:layout_width="100dp"
android:layout_height="50dp"
android:layout_weight="0.50"
android:onClick="goBack"
android:text="Back"
android:textColor="#ffffff" />
<Button
android:id="#+id/stats"
android:layout_width="100dp"
android:layout_height="50dp"
android:layout_weight="0.50"
android:onClick="goBack"
android:text="Stats"
android:textColor="#ffffff" />
</LinearLayout>
</RelativeLayout>
</LinearLayout>
</FrameLayout>

Android RelativeLayout : Placing buttons side by side next to one another

I am trying to place buttons side by side next to one another in three buttons to one row using a RelativeLayout.
This is the relative layout placed inside a linear layout with the group of buttons
main.xml
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:orientation="vertical" >
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#CC8FD8D8"
android:gravity="center"
android:orientation="vertical"
android:paddingBottom="20px" >
</RelativeLayout>
</LinearLayout>
These are the group of button found inside the layouts
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:drawableTop="#drawable/snap"
android:textColor="#FFFFFF"
android:background="#00FFFFFF"
android:id="#+id/shutterButton"
android:text="SNAP"></Button>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:drawableTop="#drawable/up"
android:textColor="#FFFFFF"
android:background="#00FFFFFF"
android:id="#+id/Up"
android:text="xxxx"></Button>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:drawableTop="#drawable/ic_action_borrow"
android:textColor="#FFFFFF"
android:background="#00FFFFFF"
android:id="#+id/xxxx"
android:text="xxxxx"></Button>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:drawableTop="#drawable/xxxx"
android:textColor="#FFFFFF"
android:background="#00FFFFFF"
android:id="#+id/xxxx"
android:text="xxxx"></Button>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:drawableTop="#drawable/xxxx"
android:textColor="#FFFFFF"
android:background="#00FFFFFF"
android:id="#+id/xxxx"
android:text="xxxx"></Button>
OUTPUT
Please how can I place the buttons one after another in 3 buttons to one row.
Kindly assist!
Try this:
XML:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:orientation="vertical">
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#CC8FD8D8"
android:gravity="center"
android:orientation="horizontal"
android:paddingBottom="20px">
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="#00FFFFFF"
android:text="SNAP"
android:textColor="#FFFFFF"></Button>
<!--android:drawableTop="#drawable/snap"-->
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="#00FFFFFF"
android:text="xxxx"
android:textColor="#FFFFFF"></Button>
<Button
android:id="#+id/xxxx"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="#00FFFFFF"
android:text="xxxxx"
android:textColor="#FFFFFF"></Button>
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#CC8FD8D8"
android:gravity="center"
android:orientation="horizontal"
android:paddingBottom="20px">
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="#00FFFFFF"
android:text="xxxx"
android:textColor="#FFFFFF"></Button>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="#00FFFFFF"
android:text="xxxx"
android:textColor="#FFFFFF"></Button>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="#00FFFFFF"
android:text="xxxx"
android:textColor="#FFFFFF"
android:visibility="invisible"></Button>
</LinearLayout>
</LinearLayout>
Output will be:
the following code creates 4 buttons side by side horizontally
<LinearLayout
android:layout_marginTop="1dp"
android:layout_marginBottom="1dp"
android:id="#+id/lay"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="50dp">
<Button
android:layout_width="0dp"
android:layout_height="match_parent"
android:id="#+id/button1"
android:text="Button1"
android:layout_weight="1"
android:padding="5dp" />
<Button
android:layout_width="0dp"
android:layout_height="match_parent"
android:id="#+id/button2"
android:text="Button2"
android:layout_weight="1"
android:padding="5dp" />
<Button
android:layout_width="0dp"
android:layout_height="match_parent"
android:id="#+id/button3"
android:text="Button3"
android:layout_weight="1"
android:padding="5dp" />
<Button
android:layout_width="0dp"
android:layout_height="match_parent"
android:id="#+id/button4"
android:text="Button4"
android:layout_weight="1"
android:padding="5dp" />
</LinearLayout>
You should linear layout for this kind of horizontal buttons and don't forget to make the orientation of inside LinearLayout to horizontal.
Like
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#CC8FD8D8"
android:gravity="center"
android:orientation="horizontal"
android:paddingBottom="20px" >
Then add buttons inside this linear layout, all the buttons will come side by side.
Try LinearLayout with android:orientation="horizontal". Check this below -
<?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="match_parent"
android:background="#CC8FD8D8"
android:gravity="center"
android:orientation="horizontal"
android:paddingBottom="20px">
<Button
android:id="#+id/shutterButton"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="#00FFFFFF"
android:drawableTop="#drawable/snap"
android:text="SNAP"
android:textColor="#FFFFFF" />
<Button
android:id="#+id/Up"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="#00FFFFFF"
android:drawableTop="#drawable/up"
android:text="xxxx"
android:textColor="#FFFFFF" />
<Button
android:id="#+id/xxxx"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="#00FFFFFF"
android:drawableTop="#drawable/ic_action_borrow"
android:text="xxxxx"
android:textColor="#FFFFFF" />
<Button
android:id="#+id/xxxx"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="#00FFFFFF"
android:drawableTop="#drawable/xxxx"
android:text="xxxx"
android:textColor="#FFFFFF" />
<Button
android:id="#+id/xxxx"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="#00FFFFFF"
android:drawableTop="#drawable/xxxx"
android:text="xxxx"
android:textColor="#FFFFFF" />
</LinearLayout>
Try this
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent">
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#CC8FD8D8"
android:gravity="center"
android:orientation="vertical"
android:paddingBottom="20px" >
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:drawableTop="#drawable/snap"
android:textColor="#FFFFFF"
android:background="#00FFFFFF"
android:id="#+id/shutterButton"
android:text="SNAP"></Button>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:drawableTop="#drawable/up"
android:textColor="#FFFFFF"
android:background="#00FFFFFF"
android:id="#+id/Up"
android:text="xxxx"
android:layout_alignParentTop="true"
android:layout_toLeftOf="#+id/xxxxx"
android:layout_toStartOf="#+id/xxxxx"
android:layout_marginRight="27dp"
android:layout_marginEnd="27dp"></Button>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:drawableTop="#drawable/ic_action_borrow"
android:textColor="#FFFFFF"
android:background="#00FFFFFF"
android:id="#+id/xxxxx"
android:text="xxxxx"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"></Button>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:drawableTop="#drawable/xxxx"
android:textColor="#FFFFFF"
android:background="#00FFFFFF"
android:id="#+id/xxxxxx"
android:text="xxxx"
android:layout_alignParentTop="true"
android:layout_toLeftOf="#+id/xxxx"
android:layout_toStartOf="#+id/xxxx"
android:layout_marginRight="50dp"
android:layout_marginEnd="50dp"></Button>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:drawableTop="#drawable/xxxx"
android:textColor="#FFFFFF"
android:background="#00FFFFFF"
android:id="#+id/xxxx"
android:text="xxxx"
android:layout_centerVertical="true"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true"></Button>
</RelativeLayout>
</LinearLayout>

How to make whole activity scrollable according to the data inside it

I have tried LinearLayout inside which I put several textview. I completely use weights for each and every view. Problem arises when data becomes too much in lenght and textview not shows it completely. I also tried tabletlayout but that thing also not works beacuse ultimately tablelayout is inside linear layout having weight,so it doesn't grows beyond a certain limit. I want to know how can I make a activity scrollable with showing all data while using weights.
Use Scrollview in xml Layout of your activity.
Example:
XML code for your activity:
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:padding="10dp"
android:fillViewport="false">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<ImageView
android:id="#+id/imageView"
android:layout_width="wrap_content"
android:layout_height="200dp"
android:scaleType="centerCrop"
android:src="#drawable/image" />
<Button
android:id="#+id/button"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="KNOW MORE" />
<TextView
android:id="#+id/textView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/title"
android:textAppearance="?android:attr/textAppearanceLarge" />
<TextView
android:id="#+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/description"
android:textAppearance="?android:attr/textAppearanceSmall" />
</LinearLayout>
</ScrollView>
You can Use Scroll View With Linear Layout as well as With Relative layout.
You Can try this code, Just Copy and paste in XML File.
U'll Get Your ans :)
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:fillViewport="true">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal"
android:background="#android:color/black"
>
<TextView
android:id="#+id/TV_Welcome"
android:text="ADD YOUR VEHICLE"
android:layout_marginLeft="70dp"
android:layout_marginTop="10dp"
android:textSize="20dp"
android:layout_centerHorizontal="true"
android:textColor="#color/menu_color"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center_vertical|center_horizontal"/>
<RelativeLayout
android:id="#+id/RelativeLayout01"
android:layout_below="#+id/TV_Welcome"
android:layout_margin="10dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<TextView
android:id="#+id/TV_BlockNo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Block No:"
android:textColor="#color/version_color"
android:layout_marginLeft="10dp"
android:textSize="15dp"
android:layout_alignParentLeft="true"
android:gravity="left"
/>
<Spinner
android:id="#+id/Spinner_BlockNo"
android:layout_marginLeft="30dp"
android:layout_toRightOf="#+id/TV_BlockNo"
android:background="#558cff"
android:layout_width="300dp"
android:layout_height="wrap_content">
</Spinner>
</RelativeLayout>
<RelativeLayout
android:id="#+id/RelativeLayout02"
android:layout_margin="10dp"
android:layout_below="#+id/RelativeLayout01"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/TV_FlatNo"
android:text="Flat NO:"
android:textSize="15dp"
android:layout_marginLeft="10dp"
android:textColor="#color/version_color"
/>
<Spinner
android:id="#+id/Spinner_FlatNo"
android:layout_marginLeft="42dp"
android:layout_toRightOf="#+id/TV_FlatNo"
android:background="#558cff"
android:layout_width="300dp"
android:layout_height="wrap_content"></Spinner>
</RelativeLayout>
<RelativeLayout
android:id="#+id/RelativeLayout03"
android:layout_below="#+id/RelativeLayout02"
android:layout_margin="10dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<TextView
android:id="#+id/TV_VehicleNo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Vehicle No:"
android:textColor="#color/version_color"
android:layout_marginLeft="10dp"
android:textSize="15dp"
android:layout_alignParentLeft="true"
android:gravity="left"
/>
<EditText
android:id="#+id/ET_VehicleNo"
android:layout_marginLeft="20dp"
android:hint="Enter Vehicle No"
android:textColorHint="#color/menu_glow"
android:textSize="20dp"
android:layout_toRightOf="#+id/TV_VehicleNo"
android:textColor="#558cff"
android:layout_width="400dp"
android:layout_height="wrap_content"
/>
</RelativeLayout>
<RelativeLayout
android:id="#+id/RelativeLayout04"
android:layout_margin="10dp"
android:layout_below="#+id/RelativeLayout03"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/TV_VehicleType"
android:text="Vehicle Type:"
android:textSize="15dp"
android:layout_marginLeft="10dp"
android:textColor="#color/version_color"
/>
<Spinner
android:id="#+id/Spinner_VehicleType"
android:layout_marginLeft="10dp"
android:layout_toRightOf="#+id/TV_VehicleType"
android:background="#558cff"
android:layout_width="300dp"
android:layout_height="wrap_content">
</Spinner>
</RelativeLayout>
<RelativeLayout
android:id="#+id/RelativeLayout05"
android:layout_margin="10dp"
android:layout_below="#id/RelativeLayout04"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<TextView
android:id="#+id/TV_OwnerName"
android:text="Owner Name:"
android:textSize="15dp"
android:textColor="#color/version_color"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:layout_alignParentLeft="true"
android:gravity="left">
</TextView>
<EditText
android:id="#+id/ET_OwnerName"
android:hint="Enter Owner Name"
android:textColorHint="#color/menu_glow"
android:inputType="textPersonName"
android:layout_marginLeft="20dp"
android:textSize="20dp"
android:layout_toRightOf="#id/TV_OwnerName"
android:textColor="#color/version_color"
android:layout_height="wrap_content"
android:layout_width="400dp">
</EditText>
</RelativeLayout>
<RelativeLayout
android:id="#+id/RelativeLayout06"
android:layout_margin="10dp"
android:layout_below="#id/RelativeLayout05"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<TextView
android:id="#+id/TV_MobileNo"
android:text="Mobile No:"
android:textSize="15dp"
android:textColor="#color/version_color"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:layout_alignParentLeft="true"
android:gravity="left">
</TextView>
<EditText
android:id="#+id/ET_MobileNo"
android:layout_marginLeft="40dp"
android:hint="Enter 10 digit"
android:textColorHint="#color/menu_glow"
android:inputType="phone"
android:textSize="20dp"
android:layout_toRightOf="#id/TV_MobileNo"
android:textColor="#color/version_color"
android:layout_height="wrap_content"
android:layout_width="200dp"
>
</EditText>
</RelativeLayout>
<RelativeLayout
android:id="#+id/RelativeLayout07"
android:layout_margin="10dp"
android:layout_below="#id/RelativeLayout06"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<TextView
android:id="#+id/TV_TelNo"
android:text="Telephone No:"
android:textSize="15dp"
android:textColor="#color/version_color"
android:layout_height="wrap_content"
android:layout_width="wrap_content">
</TextView>
<EditText
android:id="#+id/ET_TelNo"
android:layout_marginLeft="20dp"
android:hint="Enter Telephone No"
android:textColorHint="#color/menu_glow"
android:inputType="number"
android:textSize="17dp"
android:layout_toRightOf="#id/TV_TelNo"
android:textColor="#color/version_color"
android:layout_height="wrap_content"
android:layout_width="wrap_content">
</EditText>
</RelativeLayout>
<RelativeLayout
android:id="#+id/RelativeLayout08"
android:layout_margin="0dp"
android:layout_below="#id/RelativeLayout07"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<TextView
android:id="#+id/TV_Example"
android:text="(Example:0141-2206923)"
android:layout_marginLeft="120dp"
android:textSize="10dp"
android:textColor="#color/version_color"
android:layout_height="wrap_content"
android:layout_width="wrap_content">
</TextView>
</RelativeLayout>
<ImageView
android:id="#+id/ImageView_Submit"
android:layout_marginTop="5dp"
android:layout_marginLeft="100dp"
android:layout_centerInParent="true"
android:layout_width="150dp"
android:layout_height="150dp"
android:src="#drawable/submit"
android:layout_below="#id/RelativeLayout08"
android:onClick="doSubmit"></ImageView>
</RelativeLayout>
</ScrollView>
You can make your activity scrollable using ScrollView.
Its very simple and effective to use.Just copy code of ScrollView from below and paste it in your layout xml file.
You can use this ScrollView with Linear as well as Relative Layout also.
Just need to remember one thing,ScrollView can have only one child widget.If you want more Children then wrap them into one container.
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical">
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<ImageView
android:id="#+id/imageView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/xyz.png"/>
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="horizontal">
<TextView
android:id="#+id/textView1"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="TextView1"/>
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="horizontal">
<TextView
android:id="#+id/textView2"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="TextView2"/>
<TextView
android:id="#+id/textView3"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="TextView3"/>
<TextView
android:id="#+id/textView4"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="TextView4"/>
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<Button
android:id="#+id/btn_demo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:text="Demo" />
</LinearLayout>
</LinearLayout>
</ScrollView>

Not shows two last buttons with ScrollView

I am new at android. I want the page with an ImageView at top of screen , 4 buttons at bottom of page and there is one frameLayout at the middle of page. I have done with a xml file for loading in FrameLayout. it contains ScrollView and 10 buttons. but when i run the program, the last two of buttons are not showing on page after scrolling page.
can anybody help me out?
main.xml:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#drawable/background">
<ImageView
android:id="#+id/yellowbar"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:src="#drawable/smallyelowbar"
android:adjustViewBounds="true"
android:scaleType="fitXY"
android:layout_alignParentTop="true"/>
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="0"
android:layout_gravity="bottom"
android:layout_below="#id/yellowbar">
<FrameLayout
android:id="#+id/frameLayout"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1"/>
</RelativeLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_alignParentBottom="true">
<ImageView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:src="#drawable/topmenu"
android:adjustViewBounds="true"
android:scaleType="fitXY"/>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_alignParentBottom="true">
<Button android:id="#+id/btn1"
android:layout_width="0dip"
android:layout_weight="1"
android:layout_height="wrap_content"
android:background="#drawable/more_selector"/>
<Button
android:id="#+id/btn2"
android:layout_width="0dip"
android:layout_weight="1"
android:layout_height="wrap_content"
android:background="#drawable/contact_selector"/>
<Button android:id="#+id/btn3"
android:layout_width="0dip"
android:layout_weight="1"
android:layout_height="wrap_content"
android:background="#drawable/product_selector"/>
<Button android:id="#+id/btn4"
android:layout_width="0dip"
android:layout_weight="1"
android:layout_height="wrap_content"
android:background="#drawable/introduce_selector"/>
</LinearLayout>
</LinearLayout>
</RelativeLayout>
scrooll.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical">
<ScrollView
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<Button
android:id="#+id/btn1_product"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_marginRight="10dp"
android:layout_marginTop="7dp"
android:background="#drawable/product_sub_selector"
android:text="#string/btn1_product"
android:textColor="#color/white"
android:textSize="10sp"/>
<Button
android:id="#+id/btn2_product"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_marginRight="10dp"
android:layout_marginTop="7dp"
android:background="#drawable/product_sub_selector"
android:textColor="#color/white"
android:text="#string/btn2_product"
android:layout_below="#id/btn1_product"
android:textSize="10sp"/>
<Button
android:id="#+id/btn3_product"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_marginRight="10dp"
android:layout_marginTop="7dp"
android:background="#drawable/product_sub_selector"
android:textColor="#color/white"
android:text="#string/btn3_product"
android:layout_below="#id/btn2_product"
android:textSize="10sp"/>
<Button
android:id="#+id/btn4_product"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_marginRight="10dp"
android:layout_marginTop="7dp"
android:background="#drawable/product_sub_selector"
android:textColor="#color/white"
android:text="#string/btn4_product"
android:layout_below="#id/btn3_product"
android:textSize="12sp"/>
<Button
android:id="#+id/btn5_product"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_marginRight="10dp"
android:layout_marginTop="7dp"
android:background="#drawable/product_sub_selector"
android:textColor="#color/white"
android:text="#string/btn5_product"
android:layout_below="#id/btn4_product"
android:textSize="12sp"/>
<Button
android:id="#+id/btn6_product"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_marginRight="10dp"
android:layout_marginTop="7dp"
android:background="#drawable/product_sub_selector"
android:textColor="#color/white"
android:text="#string/btn6_product"
android:layout_below="#id/btn5_product"
android:textSize="12sp"/>
<Button
android:id="#+id/btn7_product"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_marginRight="10dp"
android:layout_marginTop="7dp"
android:background="#drawable/product_sub_selector"
android:textColor="#color/white"
android:text="#string/btn7_product"
android:layout_below="#id/btn6_product"
android:textSize="12sp"/>
<Button
android:id="#+id/btn8_product"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_marginRight="10dp"
android:layout_marginTop="7dp"
android:background="#drawable/product_sub_selector"
android:textColor="#color/white"
android:text="#string/btn8_product"
android:layout_below="#id/btn7_product"
android:textSize="12sp"/>
<Button
android:id="#+id/btn9_product"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_marginRight="10dp"
android:layout_marginTop="7dp"
android:background="#drawable/product_sub_selector"
android:textColor="#color/white"
android:text="#string/btn9_product"
android:layout_below="#id/btn8_product"
android:textSize="12sp"/>
<Button
android:id="#+id/btn10_product"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_marginRight="10dp"
android:layout_marginTop="7dp"
android:background="#drawable/product_sub_selector"
android:textColor="#color/white"
android:text="#string/btn10_product"
android:layout_below="#id/btn9_product"
android:textSize="12sp"/>
</RelativeLayout>
</ScrollView>
</LinearLayout>
Thanks for help.
Try giving "wrap_content" to height
<ScrollView
android:layout_width="fill_parent"
android:layout_height="wrap_content" > </ScrollView>
Add android:weightSum=4 in the last LinearLayout of first xml.
Convert RelativeLayout to LinearLayout, it will work.

Categories

Resources