Introducing marginTop in RelativeLayout creates overlapping - android

I'm trying to display information to the user through the use of a RelativeLayout but when I use layout_marginTop or paddingTop to create some spacing betweem my items the item below won't take in into account and they will both start overlapping.
Here are a few pics to help understand my problem :
Initial situation:
Adding a android:marginTop="48dip" to the TextView to better illustrate the problem:
I also tried adding the same android:marginTop="48dip" to the EditText but the result was unexpected too. (Link to the screenshot can be find in the comment as a user with less than 10 reputation can't post more than 2 links)
The Layout I'm using (simplified version)
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<RelativeLayout xmlns:local="http://schemas.android.com/apk/res-auto"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:paddingLeft="16dp"
android:paddingRight="16dp"
android:paddingTop="8dp">
<!--Identification part-->
<TextView
android:id="#+id/idPartTV"
android:text="Site"
android:textColor="#FFFFFF"
android:textSize="20sp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true" />
<View
android:id="#+id/idPartLine"
android:layout_width="wrap_content"
android:layout_height="1dp"
android:layout_below="#id/idPartTV"
android:layout_marginTop="4dip"
android:background="#android:color/darker_gray" />
<!--Site name-->
<TextView
android:id="#+id/siteNameTV"
android:text="Name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#id/idPartLine"
android:layout_marginTop="8dip" />
<EditText
android:id="#+id/siteName"
local:MvxBind="Text Name"
android:layout_below="#id/idPartLine"
android:layout_toRightOf="#+id/transTV"
android:layout_alignBaseline="#id/siteNameTV"
android:layout_width="wrap_content"
android:layout_height="48dip" />
<!--Site ID-->
<TextView
android:id="#+id/siteIdTV"
android:text="ID"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#id/siteName" />
<EditText
android:id="#+id/siteID"
local:MvxBind="Text Id"
android:layout_width="wrap_content"
android:layout_height="48dip"
android:layout_below="#id/siteName"
android:layout_toRightOf="#id/transTV"
android:layout_alignBaseline="#id/siteIdTV" />
<!--location Part-->
<TextView
android:id="#+id/locPartTV"
android:text="Location"
android:textColor="#FFFFFF"
android:textSize="20sp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#id/siteID" />
<View
android:id="#+id/locPartLine"
android:layout_width="wrap_content"
android:layout_height="1dp"
android:layout_below="#id/locPartTV"
android:background="#android:color/darker_gray"
android:layout_marginTop="4dip" />
<!--Latitude-->
<TextView
android:id="#+id/latTV"
android:text="Latitude"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#id/locPartLine" />
<EditText
android:id="#+id/latitude"
local:MvxBind="Text Latitude"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#id/locPartLine"
android:layout_toRightOf="#id/transTV"
android:layout_alignBaseline="#id/latTV"
android:inputType="numberDecimal" />
<!--Longitude-->
<TextView
android:id="#+id/longTV"
android:text="Longitude"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#id/latitude" />
<EditText
android:id="#+id/longitude"
local:MvxBind="Text Longitude"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#id/latitude"
android:layout_toRightOf="#id/transTV"
android:layout_alignBaseline="#id/longTV"
android:inputType="numberDecimal" />
</RelativeLayout>
</ScrollView>
In the snippet of code above, transTV is my largest TextView. I'm using it to be sure that all the EditText will be vertically aligned. SiteID is another EditText that is situated above the one presented here. As I had a lot of them I mutilated my code to avoid redundancies.
In my idea of the android:marginTop and of the RelativeLayout, adding some space between the latitude and the separating line should be taken into account to calculate the position of the longitude as it is set to be below the latitude using android:layout_below.

Related

Android - How to align a TextView text

I have the following layout for a ListView item:
<?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"
android:padding="5dp">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/item_icon_image"
android:layout_centerVertical="true"
android:layout_alignParentLeft="true"
android:src="#drawable/m" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Business Name"
android:id="#+id/item_title_text"
android:layout_toRightOf="#+id/item_icon_image"
android:layout_marginLeft="3dp"
android:textStyle="bold"
android:textAppearance="?android:attr/textAppearanceSmall"
android:layout_alignTop="#+id/item_icon_image" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceSmall"
android:text="Distance"
android:id="#+id/item_distance_text"
android:layout_alignLeft="#+id/item_title_text"
android:layout_alignBottom="#+id/item_icon_image" />
</RelativeLayout>
And this is the rendered result:
As you can see there is a gap between the real text and the bottom of the image... I was expecting to have the bottom of the text matching exactly with the bottom of the image...so question is: How can I align the text to the bottom of the image?
(this also happens for the top text, but in the top instead)
EDIT:
For now I am using:
android:layout_marginBottom="-10dp"
But I wanted something more automatic, some solution that won't depend on dp or screen....but as commented, this might be impossible, because the View needs to make space for letter such as 'y', 'g' and 'j'....but I wish there could be something that will align it based on it's contents, so if there wasn't a 'g', it won't be saving this space.
You should add android:gravity="top" to your top text view and android:gravity="bottom" to your bottom text view to get the desired result.
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="wrap_content"
android:padding="5dp">
<ImageView
android:id="#+id/item_icon_image"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/ic_launcher" />
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_marginLeft="5dp"
android:layout_weight="1"
android:orientation="vertical">
<TextView
android:id="#+id/item_title_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Business Name"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textStyle="bold" />
<View
android:layout_width="1dp"
android:layout_height="odp"
android:layout_weight="1"/>
<TextView
android:id="#+id/item_distance_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Distance"
android:textAppearance="?android:attr/textAppearanceSmall" />
</LinearLayout>
</LinearLayout>
Do it like this to acheive the desired result:
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceSmall"
android:text="Distance"
android:id="#+id/item_distance_text"
android:layout_alignLeft="#+id/item_title_text"
android:layout_alignBottom="#+id/item_icon_image"
android:gravity="bottom" />

How to have a layout next to TextView such that it will always be visible and close to the textview

As seen in picture below I need a layout where Textview containing contents 'Hello' and layout '2' are always visible and are between layout '1' and ']'
{1}Hello{2} ]
{1}Hello I..{2}]
If textview contents are too long they should ellipsize
Layout '2' shouldn't be right aligned to parent or ']', but be next to TextView
I have tried playing with wieghts and relative layout but do not seem to get a working solution.
Any ideas/pointers?
Here is slimdown version of my layout
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#drawable/simple_white_button"
android:orientation="horizontal" >
<RelativeLayout
android:id="#+id/topLayout1"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="0.85"
android:paddingBottom="5dp"
android:paddingLeft="5dp"
android:paddingTop="5dp" >
<ImageView
android:id="#+id/photo"
android:layout_width="75dp"
android:layout_height="75dp"
android:scaleType="centerCrop"
android:src="#drawable/headshot_alt"
android:visibility="visible" />
<LinearLayout
android:id="#+id/myRow"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_toRightOf="#id/photo" >
<TextView
android:id="#+id/address"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:layout_marginTop="2dp"
android:ellipsize="end"
android:singleLine="true"
android:text="New Jersey"
android:textColor="#color/grey_text"
android:textSize="16sp" />
<LinearLayout
android:id="#+id/weather"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginTop="2dp"
android:layout_weight="1"
android:gravity="left" >
<!-- Weather -->
<ImageView
android:id="#+id/imgWeather"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/ic_notification_news"
android:visibility="visible" />
<TextView
android:id="#+id/txtWeather"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginLeft="3dp"
android:gravity="center_vertical"
android:text="50/43"
android:textColor="#color/text_dark"
android:textSize="13sp"
android:visibility="visible" />
</LinearLayout>
</LinearLayout>
</RelativeLayout>
<LinearLayout
android:id="#+id/menu"
android:layout_width="0dp"
android:layout_height="fill_parent"
android:layout_weight="0.15"
android:background="#drawable/simple_white_button"
android:gravity="center"
android:orientation="horizontal" >
<ImageView
android:id="#+id/menu_icon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:scaleType="center"
android:src="#drawable/ic_quickaction_default" />
</LinearLayout>
</LinearLayout>
Where {1} would be the id = photo, ] is id=menu and id=myRow is the textview + weather layout i want in between photo and menu. I preferably do not want to set max width on my address text view, in worst case i want it ellipsize when weather touches the menu, But when address is small i want weather next to address and not close to menu
Hopefully its bit more clear now
In a relative layout, with fixed width for the textview, Layout'2' as layout_toRightOf the textview, something like this:
<TextView
android:id="#+id/firstText"
android:layout_width="60dp"
android:layout_height="wrap_content"
android:background="#android:color/white"
android:text="Hello String"
android:lines="1"
android:ellipsize="end"
android:textAppearance="?android:attr/textAppearanceMedium" />
<TextView
android:id="#+id/layoutTwo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toRightOf="#id/firstText"
android:background="#android:color/white"
android:text="Layout 2"
android:textAppearance="?android:attr/textAppearanceMedium" />
</RelativeLayout>
Provide the container layout as per your requirement. With a fill_parent width, you can adjust the "]" to be at the extreme right or xdp away after your Layout 2
Can you specify, precisely, what is required...i'l edit my answer

Android RelativeLayout with wrap_content truncates some children

I have a RelativeLayout whose width/height is set to wrap_content. However, the button in the bottom right is truncated on its lower side.
Changing the RelativeLayout's paddingBottom doesn't help, neither does adding a marginBottom to the button.
Any ideas?
Here's my code:
<RelativeLayout
android:id="#+id/sign_up_phase_enteraddress"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:paddingTop="10dp"
android:paddingRight="10dp"
android:paddingBottom="10dp"
android:paddingLeft="10dp"
android:background="#ff6aa639"
>
<TextView
android:id="#+id/sign_up_signuphere"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_marginBottom="29dp"
android:text="#string/sign_up_signuphere"
android:textAppearance="?android:attr/textAppearanceMedium" />
<TextView
android:id="#+id/sign_up_emaillabel"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#id/sign_up_signuphere"
android:layout_alignLeft="#id/sign_up_signuphere"
android:layout_alignBaseline="#+id/sign_up_email"
android:text="#string/sign_up_emailaddress"
android:textAppearance="?android:attr/textAppearanceMedium" />
<EditText
android:id="#+id/sign_up_email"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_marginLeft="46dp"
android:layout_below="#id/sign_up_signuphere"
android:layout_toRightOf="#id/sign_up_emaillabel"
android:ems="10"
android:inputType="textEmailAddress" >
<requestFocus />
</EditText>
<Button
android:id="#+id/sign_up_signup"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="#+id/sign_up_haveaccount"
android:layout_alignRight="#id/sign_up_email"
android:layout_below="#id/sign_up_email"
android:text="#string/sign_up_signup" />
<TextView
android:id="#+id/sign_up_haveaccount"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#id/sign_up_emaillabel"
android:layout_marginTop="27dp"
android:layout_below="#id/sign_up_email"
android:text="#string/sign_up_haveaccount"
android:textAppearance="?android:attr/textAppearanceSmall" />
</RelativeLayout>
...and this is what it looks like in the emulator:
Any thoughts on how I can get the bottom of my button to show?
TIA!
My fast idea is to set button bottom border to height of text on the left by using xml code
android:layout_alignBottom="#+id/sign_up_haveaccount"
because you've setted layout_below option already. However your xml code is quite not proper :) I will try write here better xml code for you, later.
Well, I found your problem. And I was searching for solution.
I setted for textview new padding bottom because button was aligned to this textview basline. I know that it could be a nice hack but I coudln't find andy good way to handle it :)
According to your layout I changed behaviour for edittext to make it stretchable. Also I grouped all elements into 3 groups. Each one per row to make it more readable.
Also do not forget that first 2 lines about xmls.
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="#+id/sign_up_phase_enteraddress"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:background="#ff6aa639"
android:paddingBottom="10dp"
android:paddingLeft="10dp"
android:paddingRight="10dp"
android:paddingTop="10dp" >
<!-- 1 row -->
<RelativeLayout
android:id="#+id/row1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingBottom="29dp" >
<TextView
android:id="#+id/sign_up_signuphere"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/sign_up_signuphere"
android:textAppearance="?android:attr/textAppearanceMedium" />
</RelativeLayout>
<!-- 2 row -->
<RelativeLayout
android:id="#+id/row2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/row1" >
<TextView
android:id="#+id/sign_up_emaillabel"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="#+id/sign_up_email"
android:text="#string/sign_up_emailaddress"
android:textAppearance="?android:attr/textAppearanceMedium" />
<EditText
android:id="#+id/sign_up_email"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_marginLeft="20dp"
android:layout_centerVertical="true"
android:layout_toRightOf="#+id/sign_up_emaillabel"
android:inputType="textEmailAddress" >
<requestFocus />
</EditText>
</RelativeLayout>
<!-- 3 row -->
<RelativeLayout
android:id="#+id/row3"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/row2" >
<TextView
android:id="#+id/sign_up_haveaccount"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="27dp"
android:paddingBottom="15dp"
android:text="#string/sign_up_haveaccount"
android:textAppearance="?android:attr/textAppearanceSmall" />
<Button
android:id="#+id/sign_up_signup"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="#+id/sign_up_haveaccount"
android:layout_alignParentRight="true"
android:text="#string/sign_up_signup" />
</RelativeLayout>
</RelativeLayout>
This is happening because of your padding , you have given 10 dp padding in bottom and your button view doesn't have enough space.Remove padding and check it .

Android EditText vertical sizing: I want it to be small!

Here are sample pictures of two EditText fields I've added in an Action Bar:
[This is from the Graphical Layout tool in Eclipse]
[This is what it looks like in my emulator (2.1 WVGA854)
My question is, how can I make the EditText look a bit closer to the Graphical Layout? Or is this a function of the emulation? On my device, which has a custom rom, the EditText is square but looks similar to the Graphical Layout, which is what I want.
I've tried setting the textAppearance to "#android:attr/textAppearanceSmall". This does help in that it changes the size of the text within the EditText to be viewable, but it does not affect the size of the EditText itself.
Here's the XML for my EditText:
<EditText
android:maxLines="1"
android:scrollHorizontally="true"
android:textAppearance="#android:attr/textAppearanceSmall"
android:layout_marginTop="5dip"
android:layout_marginLeft="5dip"
android:layout_marginRight="5dip"
android:layout_width="fill_parent"
android:layout_height="wrap_content" />
I could post the full XML, but essentially this EditText is enclosed (along with the search icon ImageView) in a RelativeLayout that is within another RelativeLayout.
Thanks for any help!
EDIT
By request, here is the full XML for the top search bar:
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<ImageButton
android:id="#+id/IBSearchOverlayMic"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:background="#drawable/aslctr_search_overlay_blackbutton"
android:src="#drawable/search_overlay_ic_microphone" />
<ImageView
android:id="#+id/IVSearchOverlayDivider1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toLeftOf="#id/IBSearchOverlayMic"
android:src="#drawable/search_overlay_division" />
<ImageButton
android:id="#+id/IBSearchOverlaySearch"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toLeftOf="#id/IVSearchOverlayDivider1"
android:background="#drawable/aslctr_search_overlay_blackbutton"
android:src="#drawable/search_overlay_ic_searchwhite" />
<RelativeLayout
android:id="#+id/RLSearchOverlaySearch"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignTop="#id/IBSearchOverlaySearch"
android:layout_alignBottom="#id/IBSearchOverlaySearch"
android:layout_alignParentLeft="true"
android:layout_toLeftOf="#id/IBSearchOverlaySearch"
android:layout_centerVertical="true"
android:background="#drawable/search_overlay_searchbg">
<EditText
android:id="#+id/ETSearchOverlaySearch"
android:maxLines="1"
android:scrollHorizontally="true"
android:textAppearance="#android:attr/textAppearanceSmall"
android:layout_marginTop="5dip"
android:layout_marginLeft="5dip"
android:layout_marginRight="5dip"
android:layout_width="fill_parent"
android:layout_height="wrap_content" />
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignRight="#id/ETSearchOverlaySearch"
android:layout_centerVertical="true"
android:layout_marginRight="10dip"
android:clickable="false"
android:focusable="false"
android:src="#drawable/search_actionbar_ic_searchcream" />
</RelativeLayout>
</RelativeLayout>
I determined the problem. The issue was that the EditText was inside the RelativeLayout...I think that messed with the padding, or perhaps the EditText's layout_height="wrap_content" meant that it extended vertically. Here's the reworked XML:
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<ImageButton
android:id="#+id/IBSearchOverlayMic"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:background="#drawable/aslctr_search_overlay_blackbutton"
android:src="#drawable/search_overlay_ic_microphone" />
<ImageView
android:id="#+id/IVSearchOverlayDivider1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toLeftOf="#id/IBSearchOverlayMic"
android:src="#drawable/search_overlay_division" />
<ImageButton
android:id="#+id/IBSearchOverlaySearch"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toLeftOf="#id/IVSearchOverlayDivider1"
android:background="#drawable/aslctr_search_overlay_blackbutton"
android:src="#drawable/search_overlay_ic_searchwhite" />
<ImageView
android:id="#+id/IVSearchBackground"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignTop="#id/IBSearchOverlaySearch"
android:layout_alignBottom="#id/IBSearchOverlaySearch"
android:layout_alignParentLeft="true"
android:layout_toLeftOf="#id/IBSearchOverlaySearch"
android:layout_centerVertical="true"
android:background="#drawable/search_overlay_searchbg" />
<EditText
android:id="#+id/ETSearchOverlaySearch"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignTop="#id/IBSearchOverlaySearch"
android:layout_alignBottom="#id/IBSearchOverlaySearch"
android:layout_alignParentLeft="true"
android:layout_toLeftOf="#id/IBSearchOverlaySearch"
android:layout_marginTop="5dip"
android:layout_marginLeft="5dip"
android:layout_marginRight="5dip"
android:layout_marginBottom="0dip"
android:paddingBottom="0dip"
android:maxLines="1"
android:scrollHorizontally="true" />
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toLeftOf="#id/IBSearchOverlaySearch"
android:layout_alignTop="#id/IBSearchOverlaySearch"
android:layout_alignBottom="#id/IBSearchOverlaySearch"
android:layout_centerVertical="true"
android:layout_marginRight="15dip"
android:clickable="false"
android:focusable="false"
android:src="#drawable/search_actionbar_ic_searchcream" />
</RelativeLayout>

How to get Side by Side textviews with one that wraps

I have a listview with a custom adapter in which I have 3 textviews, two are next to each other and one is below the others. The problem I am running into though, is when the first textview extends, it pushes the other textview off the screen.
I have not been able to successfully get this to work, here is an example of what's happening:
As you can see when the first textview gets too long, it then pushes the other text off the screen. I would like it so it wraps but the date textview is also showing. It should also be functional in horizontal view.
Here's the listview adapter code:
<RelativeLayout android:id="#+id/vw1" android:layout_width="fill_parent"
android:layout_height="wrap_content" android:orientation="horizontal"
android:descendantFocusability="blocksDescendants" xmlns:android="http://schemas.android.com/apk/res/android">
<TextView android:id="#+id/liName" android:textSize="17sp"
android:textColor="#333" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:gravity="left"
android:layout_gravity="left" />
<TextView android:id="#+id/liDate" android:textSize="12sp"
android:textColor="#666" android:layout_width="fill_parent"
android:layout_height="wrap_content" android:gravity="right"
android:layout_gravity="right" android:width="60sp" android:layout_toRightOf="#+id/liName" />
<TextView android:id="#+id/liNum" android:textSize="12sp"
android:textColor="#666" android:layout_width="fill_parent"
android:layout_height="wrap_content" android:layout_below="#+id/liName" />
</RelativeLayout>
I am assuming that the text view being pushed is the liDate one.
You need to put this one before the liName in your layout and set the width to "wrap_content" and align it right. Then you lace the liName to the left of it with "fill_parent" width
So it would look like this:
<RelativeLayout android:id="#+id/vw1" android:layout_width="fill_parent"
android:layout_height="wrap_content" android:orientation="horizontal"
android:descendantFocusability="blocksDescendants" xmlns:android="http://schemas.android.com/apk/res/android">
<TextView android:id="#+id/liDate" android:textSize="12sp"
android:textColor="#666" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:width="60sp"
android:layout_alignParentRight="true" />
<TextView android:id="#+id/liName" android:textSize="17sp"
android:textColor="#333" android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_toLeftOf="#id/liDate" />
<TextView android:id="#+id/liNum" android:textSize="12sp"
android:textColor="#666" android:layout_width="fill_parent"
android:layout_height="wrap_content" android:layout_below="#+id/liName" />
Hope this is what you meant
The key was using "#+id/" for the first textview instead of "#id/"
This worked for me:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content" >
<TextView
android:id="#+id/listEventTypeText"
android:layout_toLeftOf="#+id/listEventDateText"
android:layout_alignParentLeft="true"
/>
<TextView
android:id="#+id/listEventDateText"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:layout_alignParentRight="true"
android:layout_alignBaseline="#id/listEventTypeText"
/>
</RelativeLayout>

Categories

Resources