This is my first try to create an android application.
I am trying to create a layout right now and am stuck allready.
Here is what I am trying to accomplish:
Jaarverbruik
2013 - 2014
Afrekendatum Peildatum
So, the word Afrekendatum should be aligned to the left, the word Peildatum should be aligned to the right of the screen.
This is my current 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="fill_parent"
android:paddingLeft="16dp"
android:paddingRight="16dp" >
<TextView
android:id="#+id/periode"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:textSize="20sp"
android:text="#string/periode" />
<TextView
android:id="#+id/afrekendatum"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/periode"
android:layout_alignParentLeft="true"
android:text="#string/afrekendatum" />
<TextView
android:id="#+id/peildatum"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/periode"
android:layout_toRightOf="#id/afrekendatum"
android:layout_alignParentRight="true"
android:text="#string/peildatum" />
</RelativeLayout>
Sadly, the words are displayed directly behind each other.
What is the best way to fix this?
You don't need android:layout_toRightOf="#id/afrekendatum" because you have declared android:layout_alignParentRight="true". Remove it and it will work fine.
You should use something like this.
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:layout_centerHorizontal="true" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:layout_centerHorizontal="true" />
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:weightSum="2" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1" />
</LinearLayout>
</LinearLayout>
Try this...
You have to set TextView's gravity.
<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:background="#2b579a"
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=".MainActivity1" >
<TextView
android:id="#+id/periode"
android:layout_width="120dp"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:text="#string/periode"
android:textSize="20sp"
android:textColor="#FFFFFF"
android:layout_margin="10dp"/>
<TextView
android:id="#+id/afrekendatum"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:gravity="start"
android:textSize="20sp"
android:textColor="#FFFFFF"
android:layout_below="#+id/periode"
android:text="#string/afrekendatum" />
<TextView
android:id="#+id/peildatum"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_below="#+id/periode"
android:gravity="end"
android:textSize="20sp"
android:textColor="#FFFFFF"
android:layout_toRightOf="#id/afrekendatum"
android:text="#string/peildatum" />
I also attached screenshot here Genius!
Related
I know there are lots of threads with more or less same topic but none of them covers my situation:
I have a little garbage can for the delete button but it always disappears off the screen if the line of the text is too long and if its too short it's attached to the line and I just wanted to be on the right hand side of the app like the the Add_item button but since it is in a Linear Layout it does not work
ativity_main.xml
<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="com.example.owner.test24.MainActivity">
<TextView
android:id="#+id/header"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="#string/header"
android:gravity="center_vertical"
android:textColor="#color/accent"
android:textSize="24sp" />
<ImageButton
android:id="#+id/add_item"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#android:color/transparent"
android:layout_alignEnd="#+id/header"
android:layout_alignRight="#+id/header"
android:src="#drawable/add_item_button"
android:contentDescription="#string/add_item"/>
<ListView
android:id="#+id/todo_list"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/header"/>
</RelativeLayout>
to_do_item_layout.xml
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="match_parent">
<CheckBox
android:id="#+id/checkBox"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<TextView
android:id="#+id/item"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="20sp"/>
<ImageButton
android:id="#+id/btnDel"
android:src="#drawable/ic_delete_button"
android:background="#android:color/transparent"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Delete"
/>
if someone has solution please let me know.
use it, it works on every screen size
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:weightSum="1">
<CheckBox
android:id="#+id/checkBox"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="0.03"/>
<TextView
android:id="#+id/item"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="hhhhh"
android:gravity="center_horizontal"
android:textSize="20sp"
android:layout_weight="0.87"/>
<ImageButton
android:id="#+id/btnDel"
android:src="#drawable/delete_icon"
android:background="#android:color/transparent"
android:layout_width="wrap_content"
android:layout_gravity="end|center_vertical"
android:layout_height="wrap_content"
android:text="Delete"
android:layout_weight="0.1" />
</LinearLayout>
Try below one
<TextView
android:id="#+id/item"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:textSize="20sp"/>
Hopes it will solve your problem. :)
Add layout_gravity tag
android:layout_gravity="right"
Use Weight:
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:weighSum= "1">
<CheckBox
android:id="#+id/checkBox"
android:layout_width="0dip"
android:layout_height="wrap_content"
amdroid: layout_weight="0.2"
/>
<ImageButton
android:id="#+id/btnDel"
android:src="#drawable/ic_delete_button"
android:background="#android:color/transparent"
android:layout_width="0dip"
android:layout_height="wrap_content"
android:text="Delete"
amdroid: layout_weight="0.2"
/>
Currently my listview design looks like
But I want to make it look like below image
Where image will be on right hand side, title in Bold and Subtitle just below it. What changes do I need to make in my layout, Below is my code. Thanks in
advance.
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/LinearLayout1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="4dp"
android:orientation="vertical" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<ImageView
android:id="#+id/ivImage"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="8dp"
android:src="#drawable/ic_launcher"/>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical" >
<TextView
android:id="#+id/tvName"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Tom Cruise"
android:textColor="#166CED"
android:textAppearance="?android:attr/textAppearanceLarge" />
</LinearLayout>
</LinearLayout>
<TextView
android:id="#+id/tvDescriptionn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#009A57"
android:text="Description" />
</LinearLayout>
For better result to manage your view use relativelayout.
You can manage your layout as example give below-
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:card_view="http://schemas.android.com/apk/res-auto"
android:id="#+id/LinearLayout1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="4dp"
android:orientation="vertical">
<android.support.v7.widget.CardView
android:id="#+id/cardView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:layout_marginTop="5dp"
card_view:cardBackgroundColor="#color/grey">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<ImageView
android:id="#+id/arrow"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:layout_marginRight="5dp"
android:src="#drawable/arrow"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_toLeftOf="#+id/arrow"
android:orientation="vertical" >
<TextView
android:id="#+id/tvName"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Murdochs needed counselling after hacking scandle says magazine"
android:textColor="#166CED"
android:padding="5dp"
android:textAppearance="?android:attr/textAppearanceLarge" />
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<TextView
android:id="#+id/tvSubtitle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_toLeftOf="#+id/ivImage"
android:padding="5dp"
android:text="NEW YORK:The British phone hacking scandle"
android:textColor="#000"
android:textAppearance="?android:attr/textAppearanceSmall" />
<ImageView
android:id="#+id/ivImage"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="8dp"
android:layout_centerVertical="true"
android:layout_alignParentRight="true"
android:src="#drawable/ic_launcher"/>
</RelativeLayout>
</LinearLayout>
</RelativeLayout>
</android.support.v7.widget.CardView>
</LinearLayout>
I would suggest you to use relative layout . this will make your layout more flexible to edit. I have suggested a layout below , give it a try .
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:id="#+id/tvName"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_marginTop="10dp"
android:gravity="center_horizontal"
android:text="Tom Cruse"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textColor="#166CED" />
<ImageView
android:id="#+id/ivImage"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_below="#+id/tvName"
android:layout_margin="5dp"
android:src="#drawable/ic_launcher" />
<TextView
android:id="#+id/tvDescriptionn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentStart="true"
android:layout_below="#+id/tvName"
android:layout_margin="10dp"
android:layout_toLeftOf="#+id/ivImage"
android:text="Description"
android:textColor="#009A57" />
</RelativeLayout>
Please do accept this answer if it worked for you.
You have to use flowTextView jar to your project. Here you can find the jar:
https://github.com/deano2390/FlowTextView
Inside LinearLayout, place textview at the top to show the title. Make height wrap_content and width match_parent.
Below this, add linearlayout which contains textview and image. set orientation horizontal to inner liner layout.
For better placing you can always used relative layout. for example
<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="com.example.testlayout.MainActivity" >
<TextView
android:id="#+id/titleText"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="#string/hello_world" />
<TextView
android:id="#+id/descriptionText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/titleText"
android:text="description"/>
<ImageView
android:id="#+id/image"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/titleText"
android:layout_toLeftOf="#+id/rightArrow"
android:src="#drawable/ic_launcher" />
<ImageView
android:id="#+id/rightArrow"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/titleText"
android:src="#drawable/ic_launcher"
android:layout_alignParentEnd="true" />
</RelativeLayout>
I have been editing my relativelayout all day, but I cannot produce a screen that is desirable.
Currently it looks like this :
It is not centered and there is a very awkward space between the hour time and the minutes time.
I am trying to figure out how to fix it so it is centered similar to this app except I include the little h and m.
I have done a lot of research and used almost every positioning view in Relative Layout, but still cannot produce it.
Properly aligning TextViews in RelativeLayout
This is my xml file. Not sure what to do I feel like I have exhausted all my options.
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:seekarc="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
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">
<FrameLayout
android:id="#+id/seekArcContainer"
android:layout_width="350dp"
android:layout_height="wrap_content"
>
</FrameLayout>
<include
layout="#layout/controls"
android:id="#+id/controls" />
<com.triggertrap.seekarc.SeekArc
android:id="#+id/seekArc"
android:layout_width="300dp"
android:layout_height="300dp"
android:layout_gravity="center_horizontal|bottom"
seekarc:thumb="#drawable/custom_seek_arc_control_selector"
android:padding="30dp"
seekarc:rotation="0"
seekarc:startAngle="0"
seekarc:sweepAngle="360"
seekarc:touchInside="true"
seekarc:arcColor="#30ff5b56"
seekarc:progressColor="#ffff3a35"
android:layout_below="#+id/seekArcContainer"
android:layout_centerHorizontal="true" />
<TextView
android:id="#+id/hour_progress_number"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:textColor="#color/red_highlight"
android:text="00"
android:textSize="90sp"
android:layout_toStartOf="#+id/little_hour_text2"
android:layout_alignParentTop="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true" />
<TextView
android:id="#+id/minute_progress_number"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:textColor="#color/red_highlight"
android:text="00"
android:textSize="90sp"
android:layout_toStartOf="#+id/little_minute_text2"
android:layout_alignTop="#+id/hour_progress_number"
android:layout_toLeftOf="#+id/little_minute_text2" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="H"
android:textSize="24sp"
android:id="#+id/little_hour_text2"
android:textColor="#color/red_highlight"
android:layout_toStartOf="#+id/minute_progress_number"
android:layout_marginRight="45dp"
android:layout_alignBottom="#+id/hour_progress_number"
android:layout_toLeftOf="#+id/minute_progress_number" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="M"
android:textSize="24sp"
android:id="#+id/little_minute_text2"
android:textColor="#color/red_highlight"
android:layout_marginRight="36dp"
android:layout_alignRight="#+id/seekArc"
android:layout_alignEnd="#+id/seekArc"
android:layout_alignBottom="#+id/minute_progress_number" />
</RelativeLayout>
try this code, may this xml help you..you can take idea from this. if any problem, then ask...
<?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:gravity="center_horizontal"
android:orientation="vertical" >
<RelativeLayout
android:layout_width="300dp"
android:layout_height="300dp" >
<com.triggertrap.seekarc.SeekArc
android:id="#+id/seekArc"
android:layout_width="300dp"
android:layout_height="300dp"
android:layout_centerInParent="true" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:orientation="horizontal" >
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="00"
android:textSize="60sp" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="H"
android:textSize="30sp" />
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="00"
android:textSize="60sp" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="M"
android:textSize="30sp" />
</LinearLayout>
</LinearLayout>
</RelativeLayout>
</LinearLayout>
what you are looking for is here in the 2nd answer (not the accepted answer). You use a strut in the middle of the two views.
this is the example given in the answer:
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<View android:id="#+id/strut"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_centerHorizontal="true"/>
<Button
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_alignRight="#id/strut"
android:layout_alignParentLeft="true"
android:text="Left"/>
<Button
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_alignLeft="#id/strut"
android:layout_alignParentRight="true"
android:text="Right"/>
</RelativeLayout>
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.
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>