android custom listview adapter, cant move text right - android

I want to right align the greyed out text in the image below:
I have tried layout_gravity and gravity both with values right and nothing has moved it.
<?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:orientation="vertical" >
<TextView
android:id="#+id/breweryName"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:text="Large Text"
android:textAppearance="?android:attr/textAppearanceLarge" />
<LinearLayout
android:orientation="horizontal"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
>
<RatingBar android:id="#+id/starbar"
style="?android:attr/ratingBarStyleSmall"
android:layout_marginLeft="5dip"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical" />
<TextView
android:id="#+id/breweryRate"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:text="Large Text"
android:layout_gravity="right"
android:textColor="#C7C3C4"
/>
</LinearLayout>
</LinearLayout>

Change your linear layout like this and see what happens .
<LinearLayout
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
>
<RatingBar android:id="#+id/starbar"
style="?android:attr/ratingBarStyleSmall"
android:layout_marginLeft="5dip"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical" />
<TextView
android:id="#+id/breweryRate"
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:text="Large Text"
android:gravity="right"
android:textColor="#C7C3C4"
/>
</LinearLayout>

Related

Just another layout issue - layout_gravity

I'm trying to implement a layout for a table-row. I have two TextViews which should be alligned to the left and one image that should be alligned to right.
Unfortunately my layout looks like this (everything is alligned to the left):
I'm fiddling with this for over an hour now and don't get it to work. What do I have to change to get the image alligned to the right?
This is my xml:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="left"
android:orientation="vertical" >
<TextView
android:id="#+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Medium Text"
android:textAppearance="?android:attr/textAppearanceMedium" />
<TextView
android:id="#+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Medium Text"
android:textAppearance="?android:attr/textAppearanceMedium" />
</LinearLayout>
<ImageView
android:id="#+id/imageView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center|right"
android:src="#drawable/ic_launcher" />
</LinearLayout>
You can achieve the same in LinearLayout using weight but weight is only used in making complex layouts now to avoid usage of weight, I would suggest you to transform your UI in RelativeLayout. In this way, you can save a lot of extra lines of code.
<?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="wrap_content" >
<TextView
android:id="#+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Medium Text"
android:textAppearance="?android:attr/textAppearanceMedium" />
<TextView
android:id="#+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/textView1"
android:text="Medium Text"
android:textAppearance="?android:attr/textAppearanceMedium" />
<ImageView
android:id="#+id/imageView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:src="#drawable/ic_launcher" />
</RelativeLayout>
You can do it by using RelativeLayout
<?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="wrap_content"
>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_alignParentLeft="true"
android:orientation="vertical" >
<TextView
android:id="#+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Medium Text"
android:textAppearance="?android:attr/textAppearanceMedium" />
<TextView
android:id="#+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Medium Text"
android:textAppearance="?android:attr/textAppearanceMedium" />
</LinearLayout>
<ImageView
android:id="#+id/imageView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:src="#drawable/ic_launcher" />
</RelativeLayout>
or if you dont want to use RelativeLayout and want to stick with your LinearLayout then try giving weight to the first LinearLayout and layout_gravity="right|end" to the ImageView:
<?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"
android:orientation="horizontal" >
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="left"
android:orientation="vertical"
android:layout_weight="1" >
<TextView
android:id="#+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Medium Text"
android:textAppearance="?android:attr/textAppearanceMedium" />
<TextView
android:id="#+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Medium Text"
android:textAppearance="?android:attr/textAppearanceMedium" />
</LinearLayout>
<ImageView
android:id="#+id/imageView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="right"
android:src="#drawable/ic_launcher" />
</LinearLayout>
Hope this works
Try using Relative layout as the root layout. In this case I think it will fix the issue.
To avoid using a RelativeLayout, you can use layout weights to set your second LinearLayout to use all the space available :
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<LinearLayout
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="match_parent"
android:gravity="left"
android:orientation="vertical" >
Use a RelativeLayout on the parent and add the android:layout_alignParentRight="true" attribute to your image

Android SDK - Positioning elements in listview row

For some reason I'm having a hell of a time with designing using eclipse and android SDK. Making layouts is painfully hard and not as easy as WPF/Visual Studio.
I am trying to accomplish the following:
Top: what I have
Bottom: what I want to achieve
http://imgur.com/AsaTuGq
Current code:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:padding="10dip"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<TextView
android:textIsSelectable="false"
android:id="#+id/line1"
android:layout_width="match_parent"
android:layout_height="0dp"
android:textSize="18sp"
android:layout_weight="1"
android:textStyle="bold"
/>
<TextView
android:textIsSelectable="false"
android:id="#+id/line2"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:textSize="18sp"
/>
<TextView
android:textIsSelectable="false"
android:id="#+id/line3"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_gravity="center"
android:textSize="18sp"
/>
</LinearLayout>
Edit:
I've also tried using Vertical LinearLayout within a Horizontal LinearLayout but that just produced a lot of errors.
Edit2:
What's with the negative rating?
Edit3:
Tried this link: http://android-developers.blogspot.ca/2009/02/android-layout-tricks-1.html
Replacing the image with a textview but the date just aligns with the top row.. hmm
You should use a RelativeLayout:
<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="wrap_content"
tools:context=".MainActivity" >
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="false"
android:layout_alignParentTop="true"
android:orientation="vertical" >
<TextView
android:id="#+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Medium Text"
android:textAppearance="?android:attr/textAppearanceMedium" />
<TextView
android:id="#+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Medium Text"
android:textAppearance="?android:attr/textAppearanceMedium" />
</LinearLayout>
<TextView
android:id="#+id/textView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:text="Medium Text"
android:textAppearance="?android:attr/textAppearanceMedium" />
</RelativeLayout>
I would suggest a RelativeLayout for this
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:padding="10dip"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<TextView
android:textIsSelectable="false"
android:id="#+id/line1"
android:layout_width="wrap_content"
android:layout_height="0dp"
android:textSize="18sp"
android:layout_weight="1"
android:textStyle="bold"
android:layout_alignParentLeft="true"
/>
<TextView
android:textIsSelectable="false"
android:id="#+id/line2"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:textSize="18sp"
android:layout_alignParentLeft="true"
android:layout_below="#_id/line1"
/>
<TextView
android:textIsSelectable="false"
android:id="#+id/line3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:layout_alignParentRight="true"
android:textSize="18sp"
/>
</RelativeLayout>
Changes:
Changed LinearLayout to RelativeLayout used android:layout_alignParentLeft="true" for the first two lines and android:layout_below="#+id/line1" for the second line. Moved the date to the right with android:layout_alignParentRight="true" and android:gravity="center_vertical" Hope this works for what you need.

dynamic textview display in android

In my application I am showing list of datas from database in a list view.For that listview i have 1 header with 4 text views arranged horizontally..But i want this to be arranged with some space exactly between and also it should fit into every screen. Please help me.Thanks in advance.By the following code it is arranging 1 after the other without space.
My code:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="horizontal"
android:background="#ffffffff">
<TextView android:id="#+id/hdrdate"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Date"/>
<TextView android:id="#+id/hdrdateasc"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
/>
<TextView android:id="#+id/hdrdes"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Item"
/>
<TextView android:id="#+id/hdritemasc"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
/>
<TextView android:id="#+id/hdrprice"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Price"
/>
<TextView android:id="#+id/hdrpriceasc"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#000000"
/>
<TextView android:id="#+id/hdrtot"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Total"
/>
<TextView android:id="#+id/hdrtotasc"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#000000"
/>
</LinearLayout>
You can use layout margin for spacing between view like
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
To fit them on the screen you can use layout_weight.Give every view weight 1 so all will be equal.You already use fill_parent for the width of your LinearLayout.
android:layout_weight="1" for every view
try this use android:layout_weight="1"in all TextView
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="horizontal"
android:background="#ffffffff">
<TextView android:id="#+id/hdrdate"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:textColor="#ff00ff00"
android:text="Date"/>
<TextView android:id="#+id/hdrdateasc"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="gffgfg"
android:textColor="#ffff0000"
android:layout_weight="1"
/>
<TextView android:id="#+id/hdrdes"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:textColor="#FF4500"
android:text="Item"
/>
<TextView android:id="#+id/hdritemasc"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="gdgdfgsg"
android:textColor="#ff0000ff"
android:layout_weight="1"
/>
<TextView android:id="#+id/hdrprice"
android:layout_weight="1"
android:layout_width="wrap_content"
android:textColor="#ff00ff00"
android:layout_height="wrap_content"
android:text="Price"
/>
</LinearLayout>
Instead of wrap_content for widht you should use weight on your textview and weightsum on linear layout:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="horizontal"
android:background="#ffffffff"
android:weightSum="100.0">
<TextView android:id="#+id/hdrdate"
android:layout_width="0dp"
android:layout_weight="100/number of text views"
android:layout_height="wrap_content"
android:layout_marginLeft="2dp"
android:layout_marginRight="2dp"
android:text="Date"/>
....
</LinearLayout>
If you do not want to use exact values for your margins you should add some blank text views and set the weight smaller than the one of the ones in which you have text.
Here is the code,
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="horizontal"
android:background="#ffffffff">
<TextView android:id="#+id/hdrdate"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Date"
android:layout_weight="1"
android:gravity="center_horizontal"/>
<TextView android:id="#+id/hdrdateasc"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<TextView android:id="#+id/hdrdes"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Item"
android:layout_weight="1"
android:gravity="center_horizontal"/>
<TextView android:id="#+id/hdritemasc"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<TextView android:id="#+id/hdrprice"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Price"
android:layout_weight="1"
android:gravity="center_horizontal"/>
<TextView android:id="#+id/hdrpriceasc"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#000000" />
<TextView android:id="#+id/hdrtot"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Total"
android:layout_weight="1"
android:gravity="center_horizontal"/>
<TextView android:id="#+id/hdrtotasc"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#000000" />
</LinearLayout>

Android LinearLayout Alignment

Being new to android I am still learning the intricacies of layouts. I am trying to create a simple bar on top of a map. For the most part this works fine.
My issue is that I want everything to be right aligned except for the Button which I want left aligned. I have tried quite a few combinations and am unable to get desired layout.
This is beginning to make me believe my structure as a whole is not correct. This seems like there should be an easy fix. What am I missing??
<LinearLayout
android:id="#+id/transparent_panel_hud"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:gravity="right">
<Button
android:text="View"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:drawableRight="#drawable/arrow_down"
android:textSize="10sp"
android:drawablePadding="3dp"/>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:orientation="vertical"
android:paddingRight="15dp" >
<TextView
android:id="#+id/latitude"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="right"
android:gravity="right"
android:text="#string/default_latitude"
android:textSize="18sp" />
<TextView
android:id="#+id/longitude"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="right"
android:text="#string/default_longitude"
android:textSize="18sp" />
</LinearLayout>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:orientation="vertical"
android:paddingRight="10dp" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="#string/speed"
android:textSize="18sp" />
<TextView
android:id="#+id/speed"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="#string/default_speed"
android:textSize="18sp" />
</LinearLayout>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:orientation="vertical"
android:paddingRight="10dp" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="#string/heading"
android:textSize="18sp" />
<TextView
android:id="#+id/heading"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="#string/default_heading"
android:textSize="18sp" />
</LinearLayout>
</LinearLayout>![screenie][1]
Do the following changes to your XML layout, you will get the output as you mentioned. Try this.
Remove the line android:gravity="right" in LinearLayout with id=transparent_panel_hud
Keep your Button in a LinearLayout as below.
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:gravity="left" >
<Button ... as you like />
</LinearLayout>
Keep your remaing 3 vertical LinearLayouts in a LinearLayout as below.
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:gravity="right" >
<LinearLayout vertical 1 ... as you like />
<LinearLayout vertical 2 ... as you like />
<LinearLayout vertical 3 ... as you like />
</LinearLayout>
I tested above changes to your code, its working. You too check it and let me know the result.
Try this
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/transparent_panel_hud"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<Button
android:text="View"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="10sp"
android:layout_alignParentLeft="true"
android:drawablePadding="3dp"/>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:orientation="vertical"
android:id="#+id/rightlayout"
android:layout_alignParentRight="true"
android:paddingRight="10dp" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="heading"
android:textSize="18sp" />
<TextView
android:id="#+id/heading"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="default_heading"
android:textSize="18sp" />
</LinearLayout>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:layout_toLeftOf="#id/rightlayout"
android:orientation="vertical"
android:paddingRight="10dp" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="speed"
android:textSize="18sp" />
<TextView
android:id="#+id/speed"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="default_speed"
android:textSize="18sp" />
</LinearLayout>
</RelativeLayout>

Layout File - Positioning Item to Right of Another Item (Android)

I'm trying to position one item in a RelativeLayout to the right of another. In the example below I want the "," to be placed to the right of the description field. However the problem is it puts the comma on the first line next to the name field. Can anyone help?
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="horizontal"
android:padding="10sp">
<TextView
android:id="#+id/name"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<TextView
android:id="#+id/description"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#id/name" />
<TextView
android:id="#+id/descriptioncomma"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text=", "
android:layout_toRightOf="#id/description" />
Try this code, it should work:
Button used layout_toRightOf attribute with id of Textview widget.
<?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:orientation="horizontal"
android:padding="10sp">
<TextView
android:id="#+id/name"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<TextView
android:id="#+id/description"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#id/name" />
<TextView
android:id="#+id/descriptioncomma"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text=","
android:layout_below="#id/name"
android:layout_toRightOf="#id/description" />
</RelativeLayout>
In Both TextView you add text and than check it.
OK
use this one
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="horizontal"
android:padding="10sp">
<TextView
android:id="#+id/name"
android:text="na"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<TextView
android:id="#+id/description"
android:text="desc"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#id/name" />
<TextView
android:id="#+id/descriptioncomma"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text=", "
android:layout_toRightOf="#id/description"
android:layout_below="#id/name" />
</RelativeLayout>
Here it will help full : Button used layout_toRightOf attribute with id of Textview widget.
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="5dp">
<TextView
android:id="#+id/textView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:text="TextView"
android:textSize="18sp"
android:padding="10dp"/>
<Button
android:id="#+id/button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="40dp"
android:layout_toRightOf="#id/textView"
android:text="Button" />
</RelativeLayout>
Here you can find Complete examples of linear layout positioning

Categories

Resources