0

I have two text-view with two colors

  1. "qwer tyu iopasd fgh jkl zxcv bnm" and
  2. "123456789"

I want to like to design the text view one after for example next to the "qwer tyu iopasd fgh jkl zxcv bnm"it display without any space"123456789" if the first textview go to about 2 to 3 lines then what to do?

<?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">

    <TextView
        android:id="@+id/textView1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="qwer tyu iopasd fgh jkl zxcv bnm"
        android:textAppearance="?android:attr/textAppearanceLarge" />

    <TextView
        android:id="@+id/textView2"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="123456789"
        android:textAppearance="?android:attr/textAppearanceLarge" />

</LinearLayout>
appukrb
  • 1,507
  • 4
  • 24
  • 53

2 Answers2

1

i have given weight to both the text :

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:weightSum="1">
    <TextView
        android:id="@+id/textView1"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:text="qwer tyu iopasd fgh jkl zxcv bnm"
        android:textAppearance="?android:attr/textAppearanceLarge" 
        android:layout_weight="0.50"/>
    <TextView
        android:id="@+id/textView2"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:text="123456789"
        android:textAppearance="?android:attr/textAppearanceLarge" 
        android:layout_weight="0.50"
        android:paddingLeft="15dp"/>
</LinearLayout>*
Nipun Gogia
  • 1,846
  • 1
  • 11
  • 17
0

If you want the text view should show one after other in same row use the attribute in LinearLayout android:orientation="horizontal"

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="horizontal" >

if you want to add text view below other you should use the attribute android:orientation="vertical"

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical" >

without margin and padding

Updated Answer here is another solution

<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:shrinkColumns="*" >

<TableRow
    android:id="@+id/give_id"
    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="qwer tyu iopasd fgh jkl zxcv bnm"
    android:maxLines="3" />
<TextView
    android:id="@+id/textView2"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="123456789"
    />
</TableRow>
</TableLayout>
BBdev
  • 4,898
  • 2
  • 31
  • 45