Android TextView Not Wraping up the text for hindi text - android

Currently I faced a problem in an application when I was trying to display text on text view which is HINDI font text on a textView it does not wrap it. It look like
My TextView code is
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:gravity="center_horizontal"
android:padding="10dp"
android:textSize="19sp"
android:textColor="#android:color/white" />
Can anyone help me to solve this problem?

Try following properly for TextView
android:maxLines="2"

Add this for your TextView:
android:ellipsize="none"
android:singleLine="false"

Try this..
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:gravity="center_horizontal"
android:padding="10dp"
android:textSize="19sp"
android:layout_weight="1"
android:ellipsize="none"
android:maxLines="100"
android:scrollHorizontally="false"
android:textColor="#android:color/white" />

Related

How to underline text in Android Studio?

Looked everywhere, couldnt find a solution for this. Setting bold or italic is very easy, why is setting underline not as easy?
Here's my bit of relevant code:
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="#+id/forgotpasswordHolder"
android:layout_marginTop="10dp">
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Forgot your password?"
android:id="#+id/labForgotpassword"
android:textColor="#6BB08C"
android:layout_weight="1"
android:textStyle="bold|italic"
android:layout_gravity="left"
android:paddingLeft="20dp"
android:textIsSelectable="true"
android:singleLine="false" />
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Not a member?"
android:id="#+id/signup"
android:textColor="#6BB08C"
android:layout_weight="1"
android:textStyle="bold|italic"
android:singleLine="false"
android:layout_gravity="right"
android:gravity="right"
android:paddingRight="20dp"
android:textIsSelectable="true" />
</LinearLayout>
I have two "Forgot your password? and a "Not a member?" buttons, and I'd love it if I could underline the text(s).
Thanks in advance!
Use a string resource with <u> tags, like this
android:text="#string/forgotPassword"
Then in strings.xml, create a String
<string name="forgotPassword"><u>Forgot your password?</u></string>
Just create a View below the TextView
As an example...

How to character-wrap in Android textview without using singleline?

I have a textview in xml file. When a text is set in java file, if the 2nd String is too long, for example: "Hello Worlddddddddddddddddddddddddddddddddddddddddddddd", the 2nd word is not visible. It should be only one line and should not use the android:singleLine How can I solve it? Thanks in advance for the help. :)
<TextView
android:id="#+id/txtItemName"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:orientation="horizontal"
android:maxLines="1"
android:textColor="#color/white" />
if you without using singline, you can set height and weight.
android:scrollHorizontally="false"
ex :
<TextView
android:id="#+id/text"
android:text="#string/hello_world"
android:layout_width="wrap_content"
android:scrollHorizontally="false"
android:layout_height="15dp"/>
Use the XML below or refer to this SO article as this is what you really need.
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/textView"
android:ellipsize="end"
android:singleLine="true"
android:gravity="right|center_vertical"
android:maxLines="1"/>
You can use elipsize property of textview
<TextView
android:id="#+id/txtItemName"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:orientation="horizontal"
android:maxLines="1"
android:textColor="#color/white"
android:ellipsize="end" />

Text hint vertically in EditText in Android?

Check This Image:
<TextView
android:id="#+id/cusumerName"
android:layout_width="match_parent"
android:layout_height="40dp"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_marginTop="5dp"
android:paddingLeft="10dp"
android:background="#drawable/button"
android:hint="Consumer Name"
android:textColor="#660000"
android:textSize="15sp" >
</TextView>
Here I found Text hint on Top, I want it vertically, How can I do?
use this in xml of TextView:
android:hint="H\ne\nl\nl\no"

Limit the text in TextView

I have a textview Which Contains some text changes dynamically within the UI like below
layout:
<TableRow android:weightSum="2" >
<ImageButton
android:id="#+id/archive"
android:layout_width="100dp"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginRight="90dp"
android:background="#drawable/archive" />
<ImageButton
android:id="#+id/facebook"
android:layout_width="-200dp"
android:layout_height="wrap_content"
android:layout_marginRight="5dp"
android:background="#drawable/facebook" />
</TableRow>
<TableRow android:layout_marginTop="2dp" >
<TextView
android:id="#+id/titlename1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:layout_marginTop="4dp"
android:text="#string/nowplaying"
android:textColor="#000000"
android:textSize="12sp"
android:textStyle="bold|italic" />
<TextView
android:id="#+id/titlename"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:layout_marginTop="4dp"
android:layout_weight="1"
android:ellipsize="none"
android:gravity="right"
android:maxEms="25"
android:maxLines="1"
android:scrollHorizontally="false"
android:textColor="#000000"
android:textSize="11dp" />
</TableRow>
<TableRow android:layout_marginTop="2dp" >
<FrameLayout
android:id="#+id/mainlayout"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_marginLeft="0dp"
android:orientation="vertical" >
<ImageButton
android:id="#+id/playbtn"
android:layout_width="30dp"
android:layout_height="30dp"
android:background="#drawable/play" />
<ImageButton
android:id="#+id/pausebtn"
android:layout_width="30dp"
android:layout_height="30dp"
android:background="#drawable/pause" />
</FrameLayout>
<SeekBar
android:id="#+id/seekBar1"
android:layout_width="500dp"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/mainlayout"
android:layout_marginLeft="-203dp"
android:layout_marginRight="0dp" />
</TableRow>
My Problem is that when i execute my Program,my layout output:
Imagebutton1 ImageButton2
NowPlaying: SongDetails
Play/Pause SeekBar
Problem is If my SongDetails text lenght Contains 2 or 3 lines My layout is getting Disturbed?Could any one Suggest?My Requirement is to limit the text like
Song Detailssss etc......in a Same Row
Simply use android:singleLine="true", and android:ellipsize="end". So You need to update TextView code as
<TextView
.....
....
android:ellipsize="end"
android:singleLine="true" />
Refrences :
android:singleLine
android:ellipsize
try to use
android:singleLine="true"
in your textview
also you can set marquee.
Note that this marquee will work if your text line is longer then your screen size only.
Try setting android:ellipsize paremeter to "end"
Like this
android:ellipsize="end"
Try setting android:ellipsize paremeter to "end" if you want to trim the content at the end.
android:ellipsize="end"
Just remove wrap_content. That should work(haven't tried it myself recently, but I used it a couple of months ago).
Otherwise, you could cut the text manually in Java, and cut it at the first newline found.

TextView bold via XML file?

Is there a way to bold the text in a TextView via XML?
<TextView
android:textSize="12dip"
android:textAppearance="bold" -> ??
</TextView>
Thanks
I have a project in which I have the following TextView :
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textStyle="bold"
android:text="#string/app_name"
android:layout_gravity="center"
/>
So, I'm guessing you need to use android:textStyle
just use
android:textStyle="bold"
Example:
use: android:textStyle="bold"
<TextView
android:id="#+id/txtVelocidade"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="#+id/txtlatitude"
android:layout_centerHorizontal="true"
android:layout_marginBottom="34dp"
android:textStyle="bold"
android:text="Aguardando GPS"
android:textAppearance="?android:attr/textAppearanceLarge" />
Use android:textStyle="bold"
4 ways to make Android TextView Bold
like this
<TextView
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:textSize="12dip"
android:textStyle="bold"
/>
There are many ways to make Android TextView bold.
use textstyle property as bold
android:textStyle = "bold";
Just you need to use
//for bold
android:textStyle="bold"
//for italic
android:textStyle="italic"
//for normal
android:textStyle="normal"
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textStyle="bold"
android:text="#string/userName"
android:layout_gravity="left"
android:textSize="16sp"
/>

Categories

Resources