I have the following XML code (partial for this example purposes):
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:paddingLeft="0dp"
android:paddingRight="0dp" >
<RadioGroup
android:id="#+id/rgVehicle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1.5" >
<RadioButton
android:id="#+id/rbCar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:checked="true"
android:text="Car" />
<RadioButton
android:id="#+id/rbTruck"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Truck" />
<RadioButton
android:id="#+id/rbCycle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Motorcycle" />
</RadioGroup>
<EditText
android:id="#+id/etToll"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ems="10"
android:inputType="numberDecimal"
android:layout_weight=".5" />
</LinearLayout>
For smaller screen like Galaxy Nexus and Nexus One the layout comes out like this:
How do I fix it so the EditText is directly below the #6 label as shown below (no matter what size the screen is):
There you go:
<?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="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="vertical" >
<TextView
android:id="#+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="5. Vehicle type"
android:textAppearance="?android:attr/textAppearanceLarge" />
<RadioGroup
android:id="#+id/rgVehicle"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<RadioButton
android:id="#+id/rbCar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:checked="true"
android:text="Car" />
<RadioButton
android:id="#+id/rbTruck"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Truck" />
<RadioButton
android:id="#+id/rbCycle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Motorcycle" />
</RadioGroup>
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="vertical" >
<TextView
android:id="#+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="6. Total amount"
android:textAppearance="?android:attr/textAppearanceLarge" />
<EditText
android:id="#+id/etToll"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ems="10"
android:inputType="numberDecimal" />
</LinearLayout>
</LinearLayout>
Use something like this:
<tablelayout>
<tablerow android:layout_weightsum="2">
<textview android:layout_weight="1" android:text="4">
<textview android:layout_weight="1" android:text="6">
</tablerow>
<tablerow android:layout_weightsum="2">
<radiogroup android:layout_weight="1">
<!-- add radio buttons here -->
</radiogroup>
<edittext android:layout_weight="1" >
</tablerow>
</tablelayout>
Related
I'm using Relativelayout within cardview layout to show the user details. But I want to show the two button at the end with equal width on and everything in the left side of Image which will stretch from Top to bottom.
But I'm not able to do so.
here is my xml code
<?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="5dp"
android:layout_marginBottom="2dp"
app:cardCornerRadius="8dp"
app:cardElevation="8dp"
>
<ImageView
android:id="#+id/contact_profile"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="right"
android:background="#fff"
android:src="#drawable/binil"
android:padding="1dp" />
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:id="#+id/top"
android:padding="5dp">
<TextView
android:id="#+id/contact_name"
android:layout_width="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="Sagar Rawal"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:textStyle="bold" />
<TextView
android:id="#+id/contact_mobile"
android:text="9868336847"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/contact_name"
android:layout_alignParentLeft="true"
android:textStyle="bold" />
<TextView
android:id="#+id/contact_address"
android:layout_below="#+id/contact_name"
android:layout_width="wrap_content"
android:text="Jumla"
android:layout_height="wrap_content"
android:layout_marginLeft="15dp"
android:textStyle="bold"
android:layout_toRightOf="#+id/contact_mobile" />
<TextView
android:id="#+id/contact_email"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="searchbbc1881#gmail.com"
android:layout_below="#+id/contact_mobile"
android:layout_alignParentLeft="true"
android:textStyle="bold" />
<ImageButton
android:layout_below="#+id/contact_email"
android:id="#+id/call"
android:background="#drawable/shape_button"
android:layout_width="wrap_content"
android:src="#drawable/ic_call_black_24dp"
android:layout_height="wrap_content" />
<ImageButton
android:layout_toRightOf="#id/call"
android:layout_below="#+id/contact_email"
android:background="#drawable/shape_button"
android:layout_width="wrap_content"
android:src="#drawable/ic_email_black_24dp"
android:layout_height="wrap_content" />
</RelativeLayout>
</android.support.v7.widget.CardView>
My output is
But I want something similar to this
Where two buttons will equally stretch to left side of Image.
Please help
Try using LinearLayout weightSum like this
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:weightSum="100">
<TextView
android:layout_width="0dp"
android:layout_weight="50"
android:layout_height="wrap_content"
android:text="text1!" />
<TextView
android:layout_width="0dp"
android:layout_weight="50"
android:layout_height="wrap_content"
android:text="text2!" />
</LinearLayout>
Update:
Replace your code with this, it will solve your issue
<?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="2dp"
android:padding="5dp"
app:cardCornerRadius="8dp"
app:cardElevation="8dp">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:weightSum="1">
<RelativeLayout
android:id="#+id/top"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight=".7"
android:padding="5dp">
<TextView
android:id="#+id/contact_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:text="Sagar Rawal"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textStyle="bold" />
<TextView
android:id="#+id/contact_mobile"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="#+id/contact_name"
android:text="9868336847"
android:textStyle="bold" />
<TextView
android:id="#+id/contact_address"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/contact_name"
android:layout_marginLeft="15dp"
android:layout_toRightOf="#+id/contact_mobile"
android:text="Jumla"
android:textStyle="bold" />
<TextView
android:id="#+id/contact_email"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="#+id/contact_mobile"
android:text="searchbbc1881#gmail.com"
android:textStyle="bold" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/contact_email"
android:weightSum="1">
<ImageButton
android:id="#+id/call"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_below="#+id/contact_email"
android:layout_weight=".5"
android:background="#drawable/shape_button"
android:src="#drawable/ic_email_black_24dp"
/>
<ImageButton
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_below="#+id/contact_email"
android:layout_toRightOf="#id/call"
android:layout_weight=".5"
android:background="#drawable/shape_button"
android:src="#drawable/ic_email_black_24dp"
/>
</LinearLayout>
</RelativeLayout>
<ImageView
android:id="#+id/contact_profile"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight=".3"
android:background="#fff"
android:padding="1dp"
android:src="#drawable/ic_launcher_background" />
</LinearLayout>
</android.support.v7.widget.CardView>
Try to reorganize it this way:
First of all look at the image
I want to the text near the "Google" image fill the empty area under the google image, look the area under the google image (in above pic) is empty and text arent filling up there.
how can i do that?
XML FILE :::
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:card_view="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:background="#drawable/allbg">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/imageView8"
android:layout_gravity="center_horizontal"
android:background="#drawable/newstop" />
<ScrollView
android:layout_width="wrap_content"
android:layout_height="match_parent">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<!-- Name Label -->
<!-- Input Name -->
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#drawable/slidebg"
android:id="#+id/slidebg"
android:layout_margin="7dp">
<ImageView
android:layout_width="match_parent"
android:layout_height="70dp"
android:id="#+id/imgad2"
android:visibility="visible"
android:layout_marginTop="9dp"
android:layout_marginBottom="6dp"
android:layout_marginLeft="8dp"
android:layout_marginRight="6dp"
/>
</RelativeLayout>
<TableLayout android:id="#+id/TableLayout01" android:stretchColumns="*"
android:layout_height="fill_parent" android:layout_width="fill_parent"
android:layout_centerInParent="true" android:layout_below="#+id/slidebg"
android:layout_margin="5dp">
<TableRow android:id="#+id/TableRow01" android:layout_width="fill_parent"
android:layout_height="0px" android:layout_weight="1" >
<LinearLayout android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/btnshare"
android:background="#drawable/opbg"
android:text="Share"
android:paddingLeft="20dp"
android:paddingTop="4dp"
android:textSize="19dp"
android:textColor="#cccccc"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/btncopy"
android:background="#drawable/opbg"
android:text="Copy"
android:paddingLeft="20dp"
android:paddingTop="3dp"
android:textSize="19dp"
android:textColor="#cccccc"/>
</LinearLayout>
</TableRow></TableLayout>
<!-- Price Label -->
<LinearLayout android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<!-- Button Create Product -->
<Button android:id="#+id/btnSave"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Save Changes"
android:layout_weight="1"
android:visibility="gone" />
<!-- Button Create Product -->
<Button android:id="#+id/btnDelete"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Delete"
android:layout_weight="1"
android:visibility="gone" />
</LinearLayout>
<TextView android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Price"
android:paddingLeft="10dip"
android:paddingRight="10dip"
android:paddingTop="10dip"
android:textSize="17dip"
android:visibility="gone" />
<!-- Input Price -->
<EditText android:id="#+id/inputPrice"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_margin="5dip"
android:layout_marginBottom="15dip"
android:singleLine="true"
android:inputType="numberDecimal"
android:visibility="gone" />
<!-- Description Label -->
<!-- Input description -->
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:padding="16dp"
android:layout_centerVertical="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:background="#drawable/listrowbg"
android:id="#+id/card_view4"
card_view:cardCornerRadius="4dp"
android:layout_centerHorizontal="true"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:layout_marginTop="5dp"
android:layout_below="#+id/TableLayout01">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/titcon">
<TextView
android:id="#+id/tvname"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:paddingTop="6dip"
android:paddingLeft="6dip"
android:textSize="16dp"
android:textColor="#fafafa"
android:textDirection="ltr"
android:textStyle="bold"
android:maxWidth="200dp"
android:width="200dp"
android:phoneNumber="false"
android:text="Abadi - SohMj"
android:layout_marginTop="-4dp" />
<ImageView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#drawable/newshead"
android:id="#+id/titsp"
/>
</RelativeLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/titcon">
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="این متن خبر تست است!"
android:id="#+id/tvdes"
android:maxLines="90"
android:ellipsize="end"
android:textSize="18dp"
android:singleLine="false"
android:textDirection="rtl"
android:textColor="#fcf8f8f8"
android:layout_weight="0.95"
android:maxLength="20000"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true"
android:layout_toRightOf="#+id/linearLayout2"
android:layout_toEndOf="#+id/linearLayout2"
android:weightSum="1"/>
<LinearLayout
android:layout_width="130dp"
android:layout_height="130dp"
android:gravity="left|top"
android:id="#+id/linearLayout2"
android:layout_alignParentTop="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:clickable="false">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/image"
/>
</LinearLayout>
</RelativeLayout>
</RelativeLayout>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="تمامی اخبار و نوشته ها حق رپفارسی می باشد و هرگونه کپی پیگرد دارد."
android:id="#+id/textView2"
android:layout_gravity="center_horizontal"
android:layout_below="#+id/card_view4"
android:textColor="#fff"
android:textSize="14dp"
android:gravity="center"
android:textStyle="bold"
android:layout_marginTop="5dp" />
</RelativeLayout>
</ScrollView>
</LinearLayout>
Use this library for wrapping your text around image..
https://github.com/deano2390/FlowTextView
Give the number in the attribute in xml
android:maxLength="100"
You can do that by setting a Max Limit to your TextView
...
android:layout_height="wrap_content" //your ImageView Height
android:maxLines="1" //Number of Lines you need to limit
android:maxLength="10" //character limit
android:ellipsize="end"
..
..
Please try this,
android:maxLength="12"
How can I put the image view below two of the text views, tv_pw and tv_un. So that in the layout the two text views are on top of the image, while the image serves as a background for that two text views. How could I do that?
Here is my xml file:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="510dip"
android:layout_marginTop="10dip"
android:background="#DDDDDD">"
<EditText
android:id="#+id/et_pw"
android:layout_width="150dip"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/et_un"
android:layout_below="#+id/et_un"
android:background="#android:drawable/editbox_background"
android:ems="10"
android:inputType="textPassword" />
<TextView
android:id="#+id/tv_pw"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="#+id/et_pw"
android:layout_alignBottom="#+id/et_pw"
android:layout_marginRight="20dp"
android:layout_toLeftOf="#+id/et_pw"
android:text="Password:"
android:textColor="#444444"
android:textSize="10pt" />
<Button
android:id="#+id/btn_login"
android:layout_width="100dip"
android:layout_height="wrap_content"
android:layout_below="#+id/et_pw"
android:layout_centerHorizontal="true"
android:text="Login" />
<TextView
android:id="#+id/tv_un"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_alignRight="#+id/tv_pw"
android:layout_marginTop="98dp"
android:text="User Name:"
android:textColor="#444444"
android:textSize="10pt" />
<EditText
android:id="#+id/et_un"
android:layout_width="150dip"
android:layout_height="wrap_content"
android:layout_alignTop="#+id/tv_un"
android:layout_centerHorizontal="true"
android:background="#android:drawable/editbox_background"
android:ems="10"
android:inputType="text" />
<TextView
android:id="#+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/btn_login"
android:layout_centerHorizontal="true"
android:text="" />
<TextView
android:id="#+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_marginTop="32dp"
android:text="text"
android:textAppearance="?android:attr/textAppearanceLarge" />
<ImageView
android:id="#+id/imageView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_marginTop="14dp"
android:src="#drawable/bkground" />
There's a lot more in your XML but, focusing on what you are asking, you can use the margin attribute to overlap the textviews.
Try something like this
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<ImageView
android:id="#+id/image"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/myImage">
</ImageView>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#id/image"
android:layout_marginTop="-50dp"
android:orientation="vertical">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/hello_world" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/hello_world2" />
</LinearLayout>
</RelativeLayout>
In this example I wrapped the two textviews inside a linear-layout (vertical) and set the linear-layout below the imageview and a margin of -50dp so it goes up and overlap.
HIH
Another way would be to use drawableBottom="#drawable/ic_launcher" inside your textview
If you don't care about having control on how the image scales, you can set the background of a LinearLayout that's wrapped around the TextViews.
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#drawable/your_background_image_here"
android:orientation="vertical">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/text_view_1" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/text_view_2" />
</LinearLayout>
Try this way,hope this will help you to solve your problem.
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="510dp"
android:layout_marginTop="10dp"
android:orientation="vertical"
android:gravity="center"
android:background="#DDDDDD">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="98dp">
<LinearLayout
android:layout_width="110dp"
android:layout_height="wrap_content"
android:orientation="vertical"
android:background="#drawable/bkground">
<TextView
android:id="#+id/tv_un"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="User Name:"
android:textColor="#444444"
android:textSize="10pt" />
<TextView
android:id="#+id/tv_pw"
android:layout_width="110dp"
android:layout_height="wrap_content"
android:text="Password:"
android:textColor="#444444"
android:textSize="10pt" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_marginLeft="20dp">
<EditText
android:id="#+id/et_un"
android:layout_width="150dp"
android:layout_height="wrap_content"
android:background="#android:drawable/editbox_background"
android:ems="10"
android:inputType="text" />
<EditText
android:id="#+id/et_pw"
android:layout_width="150dp"
android:layout_height="wrap_content"
android:background="#android:drawable/editbox_background"
android:ems="10"
android:inputType="textPassword" />
</LinearLayout>
</LinearLayout>
<Button
android:id="#+id/btn_login"
android:layout_width="100dp"
android:layout_height="wrap_content"
android:text="Login" />
<TextView
android:id="#+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="" />
<TextView
android:id="#+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="32dp"
android:text="text"
android:textAppearance="?android:attr/textAppearanceLarge" />
</LinearLayout>
Wrap the two TextViews in linear layout with vertical orientation and assign background for linear layout.
use android:weight on the the two text views and boom
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<ImageView
android:layout_width="match_parent"
android:layout_height="wrap_content"
/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content" />
So i have a small issue. When I am in portrait mode and click on an item, the conformation page comes up and its fine. but when you turn it landscape, some text is overwritten but the button. See picture:
Overlapping
However if I click on the item in landscape, its not overlapping. Can anyone see where im going wrong.
Below is the landscape code:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="#+id/fragment_one_click_reservation_details_container"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<LinearLayout
android:id="#+id/fragment_one_click_message_layouts"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<include layout="#layout/fragment_one_click_message_layout" />
<ImageView
android:id="#+id/fragment_one_click_horizontal_line"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:src="#color/thin_line" />
<LinearLayout
android:id="#+id/fragment_one_click_reservation_detalis_layout"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:orientation="vertical" >
<RelativeLayout
android:id="#+id/fragment_one_click_reservation_number_layout"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<TextView
android:id="#+id/fragment_one_click_reservation_message_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/fragment_one_click_reservation_message_text" />
<TextView
android:id="#+id/fragment_one_click_reservation_number_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="#id/fragment_one_click_reservation_message_text"
android:layout_toRightOf="#id/fragment_one_click_reservation_message_text"
android:textColor="#color/one_click_reservation_number_text"
android:textSize="20sp"
android:textStyle="bold" />
<TextView
android:id="#+id/fragment_one_click_reservation_store_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#id/fragment_one_click_reservation_number_text"
android:text="#string/fragment_one_click_reservation_store_text" />
<TextView
android:id="#+id/fragment_one_click_reservation_store_name_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="#id/fragment_one_click_reservation_store_text"
android:layout_toRightOf="#id/fragment_one_click_reservation_store_text"
android:text="TEST TEST TEST TES"
android:layout_toLeftOf="#+id/fragment_one_click_cancel_reservation_button_tablet_land"
android:textStyle="bold" />
<TextView
android:id="#+id/fragment_one_click_reservation_until_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#id/fragment_one_click_reservation_store_text"
android:layout_marginTop="15dp"
android:text="#string/fragment_one_click_reservation_until_text" />
<TextView
android:id="#+id/fragment_one_click_reservation_until_time_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="#id/fragment_one_click_reservation_until_text"
android:layout_toRightOf="#id/fragment_one_click_reservation_until_text"
android:textStyle="bold" />
<Button
android:id="#+id/fragment_one_click_cancel_reservation_button_tablet_land"
android:layout_width="200dp"
android:layout_height="40dp"
android:layout_alignParentRight="true"
android:background="#drawable/one_click_cancel_red_button"
android:text="#string/one_click_button_cancel_reservation" />
</RelativeLayout>
</LinearLayout>
<RelativeLayout
android:id="#+id/fragment_one_click_store_details_layout"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginTop="10dp" >
<Button
android:id="#+id/fragment_one_click_store_details_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#color/grey"
android:padding="10dp"
android:text="#string/one_click_store_details" />
</RelativeLayout>
<LinearLayout
android:id="#+id/fragment_one_click_reservation_until_layout"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:orientation="vertical" >
<TextView
android:id="#+id/fragment_one_click_reservation_details_sent_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/fragment_one_click_reservation_details_sent_text" />
<LinearLayout
android:id="#+id/fragment_one_click_reservation_mobile_layout"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<TextView
android:id="#+id/fragment_one_click_reservation_mobile_message_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:text="#string/fragment_one_click_reservation_mobile_message_text" />
<TextView
android:id="#+id/fragment_one_click_reservation_mobile_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:textStyle="bold" />
</LinearLayout>
<LinearLayout
android:id="#+id/fragment_one_click_reservation_email_layout"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<TextView
android:id="#+id/fragment_one_click_reservation_email_message_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:text="#string/fragment_one_click_reservation_email_message_text" />
<TextView
android:id="#+id/fragment_one_click_reservation_email_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:textStyle="bold" />
</LinearLayout>
<Button
android:id="#+id/fragment_one_click_cancel_reservation_button_tablet_port"
android:layout_width="200dp"
android:layout_height="40dp"
android:layout_marginTop="10dp"
android:background="#drawable/one_click_cancel_red_button"
android:text="#string/one_click_button_cancel_reservation" />
<RelativeLayout
android:id="#+id/fragment_one_click_reservation_my_account_layout"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="10dp" >
<TextView
android:id="#+id/fragment_one_click_reservation_my_account_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:lines="3"
android:text="#string/fragment_one_click_reservation_my_account_text_tablet" />
<Button
android:id="#+id/fragment_one_click_account_button"
style="#style/alternatesmallbutton"
android:layout_width="140dp"
android:layout_height="35dp"
android:layout_alignParentRight="true"
android:layout_marginTop="4dp"
android:text="#string/one_click_my_account" />
</RelativeLayout>
</LinearLayout>
</LinearLayout>
<LinearLayout
android:id="#+id/progress_bar"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:gravity="center_horizontal" >
<ProgressBar
android:id="#+id/fragment_pdp_add_to_trolley_progress_collection"
style="#style/progress_spinner"
android:layout_width="40dp"
android:layout_height="40dp"
android:layout_gravity="center"
android:visibility="visible" />
</LinearLayout>
<ImageView
android:id="#+id/fragment_one_click_horizontal_line"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:src="#color/thin_line" />
</LinearLayout>
Set the WIDTH of the button to WRAP CONTENT and set PADDING for the button to make the button looks larger and set the button to the right of the ID of "Reserved At info text".
I have the following layout:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="#dimen/activity_vertical_margin"
android:paddingLeft="#dimen/activity_horizontal_margin"
android:paddingRight="#dimen/activity_horizontal_margin"
android:paddingTop="#dimen/activity_vertical_margin"
tools:context=".MainActivity" >
<EditText
android:id="#+id/etShowLog"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ems="10"
android:inputType="textMultiLine"
android:lines="12"
android:textStyle="normal"
android:paddingLeft="2dip"
android:singleLine="false"
android:textColor="#999999"
android:textSize="14dip"
android:gravity="top"
android:layout_above="#+id/btnClear" />
<Button
android:id="#+id/btnClear"
android:background="#drawable/otherbuttons"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Clear"
android:textStyle="bold"
android:textColor="#FFFFFF"
android:shadowColor="#000000"
android:shadowDx="1"
android:shadowDy="1"
android:shadowRadius="2"
android:layout_alignParentBottom="true" />
<Button
android:id="#+id/btnSave"
android:background="#drawable/otherbuttons"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Save Trip"
android:layout_gravity="right"
android:textStyle="bold"
android:textColor="#FFFFFF"
android:shadowColor="#000000"
android:shadowDx="1"
android:shadowDy="1"
android:shadowRadius="2"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true" />
</RelativeLayout>
Which displays this:
How do I edit the layout so I can display a listview underneath:
like this,remember to keep listview height in a fixer value or use weight
<?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">
<LinearLayout
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent" android:layout_marginBottom="200dp">
<LinearLayout
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="0dp" android:layout_weight="1">
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="New Button"
android:id="#+id/button"/>
<LinearLayout
android:layout_width="0px"
android:layout_height="wrap_content" android:layout_weight="1">
</LinearLayout>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="New Button"
android:id="#+id/button2"/>
</LinearLayout>
</LinearLayout>
<ListView
android:layout_width="wrap_content"
android:layout_height="200dp"
android:id="#+id/listView" android:layout_gravity="center"
android:layout_marginTop="-200dp"/>
</LinearLayout>
Wrap your Buttons in a LinearLayout. Give the ListView
android:"#+id/myListView"
android:layout_alignParentBottom="true"
and the newly created LinearLayout
android:layout_above="#id/myListView
So something like this should get you close
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="#dimen/activity_vertical_margin"
android:paddingLeft="#dimen/activity_horizontal_margin"
android:paddingRight="#dimen/activity_horizontal_margin"
android:paddingTop="#dimen/activity_vertical_margin"
tools:context=".MainActivity" >
<EditText
android:id="#+id/etShowLog"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ems="10"
android:inputType="textMultiLine"
android:lines="12"
android:textStyle="normal"
android:paddingLeft="2dip"
android:singleLine="false"
android:textColor="#999999"
android:textSize="14dip"
android:gravity="top"
android:layout_above="#+id/btnClear" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_above="#id/myListView">
<Button
android:id="#+id/btnClear"
android:background="#drawable/otherbuttons"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Clear"
android:textStyle="bold"
android:textColor="#FFFFFF"
android:shadowColor="#000000"
android:shadowDx="1"
android:shadowDy="1"
android:shadowRadius="2"
android:layout_gravity="left"/>
<Button
android:id="#+id/btnSave"
android:background="#drawable/otherbuttons"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Save Trip"
android:layout_gravity="right"
android:textStyle="bold"
android:textColor="#FFFFFF"
android:shadowColor="#000000"
android:shadowDx="1"
android:shadowDy="1"
android:shadowRadius="2"
android:layout_gravity="left" />
</LinearLayout>
<ListView
android:id="#+id/myListView"
...
android:layout_alignParentBottom="true"
</RelativeLayout>
I also took out the RelativeLayout properties that were in the Buttons and added android:layout_graivty="left"
android:layout_gravity="right"
Here is an alternative (but possibly old, I wrote it a few years ago) layout that includes two side-by-side listviews at the bottom of the view. There are a load of internal views, but you should be able to extract/convert what you need?
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout android:layout_width="fill_parent"
android:id="#+id/LinearLayout" android:layout_height="fill_parent"
xmlns:android="http://schemas.android.com/apk/res/android"
android:background="#color/darkGrey">
<TableLayout android:layout_width="wrap_content"
android:layout_height="wrap_content" android:id="#+id/TableLayout01"
android:background="#color/darkGrey">
<TableRow android:layout_width="wrap_content"
android:layout_height="wrap_content" android:id="#+id/TableRow01">
<LinearLayout android:layout_width="wrap_content"
android:layout_height="wrap_content" android:id="#+id/LinearLayout01">
<TextView android:id="#+id/strap" android:layout_width="wrap_content"
android:layout_height="fill_parent" android:textSize="18sp"
android:text="Pace/Distance/Time\nCalculator" android:textColor="#color/white"
android:width="170dip" android:layout_alignParentLeft="true"
android:layout_alignParentTop="true" />
<Spinner android:layout_height="wrap_content"
android:layout_width="wrap_content" android:id="#+id/Spinner01"
android:layout_toRightOf="#+id/strap" android:prompt="#string/Presets" />
</LinearLayout>
</TableRow>
<TableRow android:layout_width="wrap_content"
android:layout_height="wrap_content" android:id="#+id/TableRow02">
<LinearLayout android:layout_width="wrap_content"
android:layout_height="wrap_content" android:id="#+id/LinearLayout02">
<TextView android:id="#+id/topline1" android:layout_width="wrap_content"
android:layout_below="#+id/strap" android:layout_height="wrap_content"
android:text=" Hour" android:width="80dip" />
<TextView android:id="#+id/topline2" android:layout_width="wrap_content"
android:layout_below="#+id/strap" android:layout_height="wrap_content"
android:layout_toRightOf="#+id/topline1" android:text="Mins"
android:width="80dip" />
<TextView android:id="#+id/topline3" android:layout_width="wrap_content"
android:layout_below="#+id/strap" android:layout_height="wrap_content"
android:layout_toRightOf="#+id/topline2" android:text="Secs" />
</LinearLayout>
</TableRow>
<TableRow android:layout_width="wrap_content"
android:layout_height="wrap_content" android:id="#+id/TableRow03">
<LinearLayout android:layout_width="wrap_content"
android:layout_height="wrap_content" android:id="#+id/LinearLayout03">
<EditText android:text="a" android:id="#+id/EditText01a"
android:layout_below="#+id/strap" android:layout_width="fill_parent"
android:layout_height="wrap_content" android:layout_weight="1"
android:maxLength="2" android:inputType="number" />
<EditText android:text="b" android:id="#+id/EditText01b"
android:layout_width="fill_parent" android:layout_height="wrap_content"
android:layout_weight="1" android:maxLength="2" android:inputType="number" />
<EditText android:text="c" android:id="#+id/EditText01c"
android:layout_width="fill_parent" android:layout_height="wrap_content"
android:layout_weight="1" android:maxLength="6" android:inputType="numberDecimal" />
<Button android:layout_width="fill_parent" android:text="Time"
android:layout_height="wrap_content" android:layout_weight="1"
android:onClick="myClickHandler" android:id="#+id/Button01" />
</LinearLayout>
</TableRow>
<TableRow android:layout_width="wrap_content"
android:layout_height="wrap_content" android:id="#+id/TableRow04">
<LinearLayout android:layout_width="wrap_content"
android:layout_height="wrap_content" android:id="#+id/LinearLayout04">
<TextView android:id="#+id/midline1" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:text=" Enter Distance (miles)" />
</LinearLayout>
</TableRow>
<TableRow android:layout_width="wrap_content"
android:layout_height="wrap_content" android:id="#+id/TableRow05">
<LinearLayout android:layout_width="wrap_content"
android:layout_height="wrap_content" android:id="#+id/LinearLayout05">
<EditText android:layout_height="wrap_content"
android:text="#+id/EditText02" android:layout_width="wrap_content"
android:id="#+id/EditText02" android:inputType="numberDecimal"
android:maxLength="8" android:width="120dip" />
<Button android:id="#+id/Button02" android:layout_height="wrap_content"
android:layout_width="wrap_content" android:layout_toRightOf="#+id/EditText02"
android:layout_below="#+id/midline1" android:text="Distance"
android:layout_marginLeft="103dip" android:width="100dip"
android:maxWidth="100dip" android:onClick="myClickHandler" />
</LinearLayout>
</TableRow>
<TableRow android:layout_width="wrap_content"
android:layout_height="wrap_content" android:id="#+id/TableRow06">
<LinearLayout android:layout_width="wrap_content"
android:layout_height="wrap_content" android:id="#+id/LinearLayout06">
<TextView android:id="#+id/topline1" android:layout_width="wrap_content"
android:layout_below="#+id/strap" android:layout_height="wrap_content"
android:text=" Hour" android:width="80dip" />
<TextView android:id="#+id/topline2" android:layout_width="wrap_content"
android:layout_below="#+id/strap" android:layout_height="wrap_content"
android:layout_toRightOf="#+id/topline1" android:text="Mins"
android:width="80dip" />
<TextView android:id="#+id/topline3" android:layout_width="wrap_content"
android:layout_below="#+id/strap" android:layout_height="wrap_content"
android:layout_toRightOf="#+id/topline2" android:text="Secs" />
</LinearLayout>
</TableRow>
<TableRow android:layout_width="wrap_content"
android:layout_height="wrap_content" android:id="#+id/TableRow07">
<LinearLayout android:layout_width="wrap_content"
android:layout_height="wrap_content" android:id="#+id/LinearLayout07">
<EditText android:text="a2" android:id="#+id/EditText03a"
android:layout_below="#+id/strap" android:layout_width="fill_parent"
android:layout_height="wrap_content" android:layout_weight="1"
android:maxLength="2" android:inputType="number" />
<EditText android:text="b2" android:id="#+id/EditText03b"
android:layout_width="fill_parent" android:layout_height="wrap_content"
android:layout_weight="1" android:maxLength="2" android:inputType="number" />
<EditText android:text="c2" android:id="#+id/EditText03c"
android:layout_width="fill_parent" android:layout_height="wrap_content"
android:layout_weight="1" android:maxLength="6" android:inputType="numberDecimal" />
<Button android:layout_width="fill_parent" android:text="Pace"
android:layout_height="wrap_content" android:layout_weight="1"
android:onClick="myClickHandler" android:id="#+id/Button03" />
</LinearLayout>
</TableRow>
<TableRow android:layout_width="wrap_content"
android:layout_height="wrap_content" android:id="#+id/TableRow08"
android:background="#color/darkGrey">
<LinearLayout android:layout_width="wrap_content"
android:layout_height="wrap_content" android:id="#+id/LinearLayout08"
android:background="#color/darkGrey">
<ListView android:id="#+id/ListView01"
android:layout_weight="1" android:layout_height="wrap_content"
android:layout_width="fill_parent" android:background="#color/darkGrey" />
<ListView android:id="#+id/ListView02"
android:layout_weight="1" android:layout_width="fill_parent"
android:layout_height="wrap_content" android:layout_toRightOf="#+id/ListView01"
android:background="#color/darkGrey2" />
</LinearLayout>
</TableRow>
</TableLayout>