1

Hi I am developing small android application in which I am displaying simple text view. In text view if I am entering large word and if it is not fitting into that line; it will start at new line.But I want to start that word on same.My code looks like

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:orientation="horizontal">
    <TextView
        android:id="@+id/policyTv"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:text="policy_no"
        android:textSize="18sp"
        android:textColor="#ff0000"
        android:layout_weight="1"
        />
    <TextView
        android:id="@+id/policyValTv"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:text=": dfsdlfnsdlfndlnlnfjdnlkdnnvdlnvldnvnflvnflsnvvmsfnlnvfnvjnmvjlsvnjlsf"
        android:textSize="18sp"
        android:textColor="#ff0000"
        android:layout_weight="2"/>
</LinearLayout>
 // output of above code looks like 
   polycy_no :
       dfsdlfnsdlfndlnlnfjdnlkdnnvdlnvldnvnflvnflsnvvmsfnlnvfnvjnmvjlsvnjlsf
 //Instead of that I am expecting 
 polycy_no : dfsdlfnsdlfndlnlnfjdnlkdnnvdlnvldnvnflvnflsnvvmsfncccscs

Is this possible? Need some help. Thank you.

nilkash
  • 7,408
  • 32
  • 99
  • 176

2 Answers2

3

Replace your standard space with \u00A0 inside Java String or &#160; in your layout or resource files. This is the UTF-8 char that represent a non breaking space.

Mimmo Grottoli
  • 5,758
  • 2
  • 17
  • 27
0

you can use

 android:singleLine="true" 

and use this also if you have to show ... in the text

 android:ellipsize="end"

android:lines="1" will not help you i have tried that in your condition.

and if you want to show the whole text in one line then you can use Marqquee for reference check below link

Marquee text in Android

Community
  • 1
  • 1
Moubeen Farooq Khan
  • 2,875
  • 1
  • 11
  • 26
  • 1
    If I use `android:singleLine="true"` then it will contain only one line. But I need multi line result as well – nilkash Jul 23 '15 at 09:59