i am using two textviews to display total balance for this i am using two textviews the first textview has a large text string and second one will have amount that is also a large number. the problem is that when content loads the text of first string is under text of second string. how to fix this?
here is my code any help will be appreciated
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/rlaout_balance_list_item"
android:orientation="horizontal"
android:weightSum="10"
>
<TextView
android:layout_width="0dp"
android:layout_height="?android:attr/listPreferredItemHeight"
android:text="type"
android:id="#+id/txt_balance_list_footer_item_type"
android:gravity="center_vertical"
android:paddingLeft="10dp"
android:textStyle="bold"
android:textColor="#000000"
android:textSize="#dimen/balance_list_item"
android:layout_weight="8"/>
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:id="#+id/txt_balance_list_footer_item_value"
android:text="0.0"
android:paddingLeft="10dp"
android:textColor="#color/balance_list_cash"
android:textStyle="bold"
android:textSize="#dimen/balance_list_item"
android:layout_weight="2"/>
</LinearLayout>
Use Relative layout instead of linear
<RelativeLayout
android:id="#+id/rlaout_balance_list_item"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<TextView
android:id="#+id/txt_balance_list_footer_item_value"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:paddingLeft="10dp"
android:text="0.0"
android:textColor="#color/balance_list_cash"
android:textSize="#dimen/balance_list_item"
android:textStyle="bold" />
<TextView
android:id="#+id/txt_balance_list_footer_item_type"
android:layout_width="wrap_content"
android:layout_height="?android:attr/listPreferredItemHeight"
android:layout_alignParentLeft="true"
android:layout_toLeftOf="#id/txt_balance_list_footer_item_value"
android:gravity="center_vertical"
android:paddingLeft="10dp"
android:textColor="#000000"
android:textSize="#dimen/balance_list_item"
android:textStyle="bold" />
</RelativeLayout>
<LinearLayout
android:id="#+id/rlaout_balance_list_item"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:weightSum="1">
<TextView
android:id="#+id/txt_balance_list_footer_item_type"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="0.3"
android:gravity="center_vertical"
android:paddingLeft="10dp"
android:text="type"
android:textColor="#000000"
android:textSize="40dp"
android:textStyle="bold" />
<TextView
android:id="#+id/txt_balance_list_footer_item_value"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="0.7"
android:paddingLeft="10dp"
android:text="0.0"
android:textSize="40dp"
android:textStyle="bold" />
</LinearLayout>
You will never get the result as you want if you use a layout like this. Please change the android:orientation="horizontal" to android:orientation="vertical"
Otherwise try something like this
<?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="horizontal">
<TextView
android:id="#+id/textView8"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="8"
android:gravity="start"
android:text="TextViecxvvvvvvvvvvvvvvvcvxbcxv
bcxvbcxvvvvvvvvvvvbcxvbcxvbcxvbcxvbcvbcxvbcxvbcxvbcxvbcxvbnbm,vvvvvvvvvvvvvvvvvvvvvvvvvvvcbbbbbbbbbbbbbbbbbbbbbbbvw" />
<TextView
android:id="#+id/textView9"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="end"
android:layout_weight="2"
android:text="cvxvxvxvxvxvxvxvxvxvxvxvxvxvxvxvxvxvxvxvxvxvxvxvxvxvxvxb" />
Related
I'm trying to align an image image with space at top of pictureat the top of a Linear Layout in android studio.I have a space as you can see on the picture. I would like to get rid of that space. Tried few things without success!!! Anyone has a clue how to do it??? Thanks
<?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:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context="com.bourgeois.michel.relativesinglescreenapp.MainActivity">
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/topLinear"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<ImageView
android:id="#+id/toppicture"
android:layout_width="match_parent"
android:layout_height="300dp"
android:src="#drawable/danielarias" />
<TextView
android:id="#+id/phone"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingBottom="10dp"
android:textColor="#ff6600"
android:textStyle="bold"
android:paddingLeft="10dp"
android:text="Phone"/>
<TextView
android:id="#+id/number"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingLeft="10dp"
android:textColor="#000"
android:textStyle="normal"
android:text="424-278-8938"/>
<View
android:id="#+id/line"
android:layout_width="fill_parent"
android:layout_height="2dp"
android:layout_marginTop="2dp"
android:layout_marginBottom="10dp"
android:background="#ff6600"/>
</LinearLayout>
<LinearLayout mlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView
android:id="#+id/address"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_above="#+id/text"
android:paddingBottom="20dp"
android:paddingLeft="10dp"
android:textColor="#000"
android:textStyle="bold"
android:text="Address: 5867 W 3rd St, Los Angeles, CA 90036"
/>
<TextView
android:id="#+id/text"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_above="#+id/button"
android:fontFamily="sans-serif-condensed"
android:paddingBottom="1dp"
android:textAlignment="center"
android:textColor="#000"
android:textSize="16sp"
android:text="Learn How To Dance Milonguero Tango Style!"/>
<TextView
android:id="#+id/thursday"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:fontFamily="sans-serif-condensed"
android:paddingBottom="5dp"
android:textAlignment="center"
android:textColor="#000"
android:textSize="16sp"
android:text="Every Thursday Night"/>
<TextView
android:id="#+id/hour"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:fontFamily="sans-serif-condensed"
android:paddingBottom="5dp"
android:textAlignment="center"
android:textColor="#000"
android:textSize="16sp"
android:text=" 8:30pm to 9:30pm"/>
<Button
android:id="#+id/button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginBottom="15dp"
android:text="Join Us" />
Use your ImageView like :
<ImageView
android:layout_width="match_parent"
android:layout_height="300dp"
android:scaleType="fitXY"/>
Problem can be about your image sources width and height. There is no marginTop in your xml. Give a try like adding android:scaleType="fitXY" to your ImageView.
try adding
android:adjustViewBounds="true"
in ImageView parameters,adding scaleType="fitXY" will stretch the image so avoid it.
Searched and found many solutions but nothing seems to be working in my case.
I have 2 TextViews, side by side. This is what i am getting in preview.
and I want this
I have written following code, but its not giving me desired output.
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:orientation="horizontal">
<TextView
android:id="#+id/tvContactsHeading"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="right"
android:textSize="18sp"
android:paddingRight="10dp"
android:text="Heading "
android:textStyle="bold"
android:fontFamily="sans-serif-regular"
/>
<TextView
android:id="#+id/tvContactsText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:textSize="18sp"
android:text="Text "
android:textStyle="normal"
android:fontFamily="sans-serif-regular"
/>
</LinearLayout>
</RelativeLayout>
If i use android:layout_gravity to left or right, it takes the whole text to left or right side.. I want to put both text in center, one starts from right corner and other starts from left corner.
Kindly guide me.
I have checked below XML file by myself ..
just put android:layout_weight="1" for both TextView and make android:layout_width="0dp" for both TextView..
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:id="#+id/linearLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:fontFamily="sans-serif-regular"
android:gravity="right"
android:paddingRight="10dp"
android:text="this code is working fine for me"
android:textSize="18sp"
android:textStyle="bold" />
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:fontFamily="sans-serif-regular"
android:gravity="left"
android:text="this is right side of the layout"
android:textSize="18sp"
android:textStyle="normal" />
</LinearLayout>
</RelativeLayout>
hope it will help u :)
You have to give match_parent width to LinearLayout.
Use this code.
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:orientation="horizontal"
android:weightSum="1">
<TextView
android:id="#+id/tvContactsHeading"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="right"
android:textSize="18sp"
android:text="HeadingShort"
android:textStyle="bold"
android:paddingRight="10dp"
android:layout_weight="0.5"
android:fontFamily="sans-serif-regular"
/>
<TextView
android:id="#+id/tvContactsText"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="left"
android:textSize="18sp"
android:text="TextShort"
android:textStyle="normal"
android:layout_weight="0.5"
android:fontFamily="sans-serif-regular"
/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:orientation="horizontal"
android:layout_weight="1.0"
android:layout_marginTop="20dp">
<TextView
android:id="#+id/tvContactsHeading2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="right"
android:textSize="18sp"
android:text="HeadingLongggg"
android:textStyle="bold"
android:paddingRight="10dp"
android:layout_weight="0.5"
android:fontFamily="sans-serif-regular"
/>
<TextView
android:id="#+id/tvContactsText2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="left"
android:textSize="18sp"
android:text="HeadingLoggg"
android:textStyle="normal"
android:layout_weight="0.5"
android:fontFamily="sans-serif-regular"
/>
</LinearLayout>
</RelativeLayout>
Your Output is
<TextView
android:id="#+id/tvContactsHeading"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="18sp"
android:paddingRight="10dp"
android:text="Heading "
android:textStyle="bold"
android:gravity="right|center_vertical|center_horizontal"
android:fontFamily="sans-serif-regular"
/>
<TextView
android:id="#+id/tvContactsText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="18sp"
android:text="Text "
android:textStyle="normal"
android:gravity="center|center_vertical|center_horizontal"
android:fontFamily="sans-serif-regular"
/>
You can add android:layout_weight=1 for each text and then change the gravity as you like
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:orientation="horizontal">
<TextView
android:id="#+id/tvContactsHeading"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:textSize="18sp"
android:paddingRight="10dp"
android:text="Heading "
android:textStyle="bold"
android:fontFamily="sans-serif-regular"
android:layout_weight="1"
/>
<TextView
android:id="#+id/tvContactsText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:textSize="18sp"
android:text="Text "
android:textStyle="normal"
android:fontFamily="sans-serif-regular"
android:layout_weight="1"
/>
</LinearLayout>
Also you can do that with relative layout which will be better
Set the layout_widthto match_parentand then apply your desired gravity.
The LinearLayoutdoes not allow you to place items on the right. So you have to set the TextViewto a full width, so you can apply the gravity for it's contents.
The other options is, that you could replace LinearLayoutwith FrameLayout.
The FrameLayoutallows absolute positioning, the LinearLayoutdoes not, which would not require to set the TextViewto a full width.
I have problem with my TextView, when something is written in it. It narrows the right layout.
like here:
1 Without something is written: http://i.stack.imgur.com/zItJw.jpg
2.Without something is written in: http://i.stack.imgur.com/b5Nb4.jpg
My Layout Code:
1st bar:
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_gravity="center"
android:layout_weight="1"
android:background="#drawable/czas_punkty_bez_napisu"
android:orientation="vertical" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="center"
android:gravity="center"
android:orientation="horizontal" >
<TextView
android:id="#+id/dzialanie"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:textSize="25sp"
android:text="X razy Y" />
<TextView
android:id="#+id/equal"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:textSize="25sp"
android:text="=" />
<TextView
android:id="#+id/tylemabyc"
android:textSize="25sp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center" />
</LinearLayout>
</LinearLayout>
2nd bar
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginBottom="5dp"
android:layout_marginTop="20dp"
android:layout_weight="1"
android:background="#drawable/czas_punkty_bez_napisu"
android:gravity="center"
android:orientation="vertical" >
<TextView
android:id="#+id/czas"
android:textSize="25sp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
/>
</LinearLayout>
3rd bar:
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginBottom="5dp"
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp"
android:layout_marginTop="20dp"
android:layout_weight="1"
android:background="#drawable/czas_punkty_bez_napisu"
android:gravity="center"
android:orientation="vertical" >
<TextView
android:id="#+id/wynik"
android:textSize="25sp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
/>
</LinearLayout>
How to block 1st TextView to not narrows others ?
You can use layout_weight property to tell android how much space each textView takes on the screen. If you want all of them to have the same space you can add the layout_weight of 1 for all of them.
You will also need to readjust your layout_width too. You will have to trade off for the layout_heght. For example if i want 4 textviews in a horizontal line holding equal space "Horizontally" i would do something like this:
<?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="horizontal" >
<TextView
android:id="#+id/textView1"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="This is verrry long text" />
<TextView
android:id="#+id/textView2"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="maybe not" />
<TextView
android:id="#+id/textView3"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="let us see" />
<TextView
android:id="#+id/textView4"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="ok" />
I thought this will be a common question, but I couldn't find any answers......
Is it possible to center-aligned a (variable length) textview based on a percentage of the screen width?
In my case, I have 2 textview and I want to achieve something like this:
Another example:
The first textview is center-aligend 30% of the screenwidth, width=wrap_content, while the second textview takes up the rest of the space. The first textview's size should NOT be fixed (see picture above)
I do not want to do that programatically, as it will be expensive on my program. If possible it's better be in an xml layout file :)
Right now I can only achieve a "left-aligned" textview using layout_weight of LinearLayout (by putting a 30% dummy on the left), but I want center-alignment.
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<View
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_weight="3" >
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="7"
android:orientation="horizontal" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="textview" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ellipsize="end"
android:singleLine="true"
android:text="another textview"
android:textColor="#FFFF0000"/>
</LinearLayout>
</LinearLayout>
With almost an hour testing this "..." layout, I succeeded with this :
<?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"
android:weightSum="100" >
<RelativeLayout
android:layout_width="0dip"
android:layout_height="wrap_content"
android:layout_weight="40"
android:background="#android:color/transparent">
<RelativeLayout
android:id="#+id/left_layout"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_margin="0dp"
android:gravity="center"
android:padding="0dp"
android:singleLine="true"
android:text="first textview"
android:textColor="#FFFF0000" >
<View
android:layout_width="1dp"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:background="#0000FF" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:background="#00FF00"
android:gravity="center"
android:text="textview"
android:textColor="#FFF" />
</RelativeLayout>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_toLeftOf="#id/left_layout"
android:background="#0000FF"
android:gravity="center"
android:text="textview"
android:textColor="#FFF" />
</RelativeLayout>
<TextView
android:layout_width="0dip"
android:layout_height="wrap_content"
android:layout_weight="60"
android:background="#FFFF0000"
android:gravity="right"
android:singleLine="true"
android:text="another textview"
android:textColor="#FFF" />
</LinearLayout>
Outputs
Finally in your Java, according to the green textview width or content length, you can change the layout_weight for other textviews programmatically.
This should help you
Have a nice day.
// try this way hope this will help you...
<?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">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<View
android:layout_width="0dp"
android:layout_height="1dp"
android:layout_weight="0.15"/>
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="0.85">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="left"
android:text="first Textview"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="second textview demo text "/>
</LinearLayout>
</LinearLayout>
</LinearLayout>
try this one
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="3"
android:gravity="center_horizontal"
android:orientation="vertical" >
<TextView
android:id="#+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="TextView" />
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="7"
android:gravity="center_horizontal"
android:orientation="vertical" >
<TextView
android:id="#+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Large Text"
android:textAppearance="?android:attr/textAppearanceLarge" />
</LinearLayout>
Work perfect checked by me.
This is what I want to achieve:
main.xml
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_marginLeft="15dp"
android:layout_marginRight="15dp" >
<TextView
android:id="#+id/tvNameContainer"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="3dp"
android:layout_marginLeft="2dip"
android:layout_weight="0.29"
android:textColor="#FFF"
android:gravity="center_horizontal"
android:text="#string/fullname"
android:textStyle="bold" />
<TextView
android:id="#+id/tvDiagnosisContainer"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginBottom="3dp"
android:layout_weight="0.57"
android:gravity="center_horizontal"
android:text="#string/diagnosis"
android:textColor="#color/white"
android:textStyle="bold" />
</LinearLayout>
custom_row.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_marginLeft="15dp"
android:layout_marginRight="15dp" >
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<TextView
android:id="#+id/fullname"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="10dp"
android:layout_weight="0.29"
android:text="text"
android:textColor="#color/black" />
<TextView
android:id="#+id/lname"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="0.29"
android:text="text"
android:textColor="#color/black" />
<TextView
android:id="#+id/diagnosis"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="0.57"
android:text="#string/diagnosis"
android:padding="5dp"
android:textColor="#color/black" />
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<TextView
android:id="#+id/lastffupcontainer"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/lastffup"
android:padding="5dp"
android:textColor="#color/black" />
<TextView
android:id="#+id/lastffup"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/lastffup"
android:padding="5dp"
android:textColor="#color/black" />
</LinearLayout>
</LinearLayout>
This is the result:
But I can't seem to make those spaces between the textviews. Any ideas?
Correct me if I'm wrong but it looks like the only issue you are having is having the "Diagnosis" TextView in the ListView spaced more to the right. For this I would change that LinearLayout to a RelativeLayout. Then you can give it the property android:layout_alignParentRight="true" and add in some android:marginRight="some dp" if needed.
You can use Android's new fancy GridLayout (http://developer.android.com/reference/android/widget/GridLayout.html or http://developer.android.com/reference/android/support/v7/widget/GridLayout.html) to get exactly what you're looking for.
Try and replace your LinearLayout tags with GridLayout instead and it just might work for you. (make sure you add the support library to your project if you need to support devices < api 14).