How to underline text in Android Studio? - android

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...

Related

How to ellipsize a TextView in between an ImageView and a TextView?

Here is my layout:
<LinearLayout
android:layout_width="match_parent"
android:layout_height="65dp"
android:layout_marginStart="20dp"
android:gravity="center_vertical|start"
android:orientation="horizontal">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="18.9dp"
android:lineSpacingExtra="64sp"
android:textColor="#484848"
android:textSize="16sp"
tools:text="அனைத்து அனைத்துஅனைத்து" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="50dp"
android:lineSpacingExtra="64sp"
android:text="0"
android:textAlignment="center"
android:textColor="#color/red_500"
android:textSize="14sp" />
</LinearLayout>
All other languages are working fine, except tamil language is very big.
I need an icon at beginning and sometimes it show number of notifications at end. So I need to set ellipsize to text on middle.
How to achieve this?
you can use android:ellipsize atrribute to do that.
like this :
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="18.9dp"
android:lineSpacingExtra="64sp"
android:textColor="#484848"
android:textSize="16sp"
android:ellipsize="end"
android:maxLines="1"
tools:text="அனைத்து அனைத்துஅனைத்து" />
note: don't forget to use android:maxLines attribute to set the line number of your text.

How to display two TextView one(key) by one(value) in android?

Can anyone please help me to design two TextViews one by one like question and answer.
Ex: Signal Strength = Excellent. Plese see the attachment Image.
https://developer.android.com/reference/android/widget/LinearLayout.html
<LinearLayout
android:width="match_parent"
android:height="wrap_content"
android:orientation="vertical">
<TextView
android:width="match_parent"
android:height="wrap_content"
android:text="signal strength"/>
<TextView
android:width="match_parent"
android:height="wrap_content"
android:text="Excellent"/>
</LinearLayout>
you can use TextInputLayout
<android.support.design.widget.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<EditText
android:textStyle="bold"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Excellent"
android:inputType="none"
android:hint="Signal Strength" />
</android.support.design.widget.TextInputLayout>
I think it will help you...
let me know if any query
Happy Coding.
Just use 2 TextView object in xml and style them according to your design. You can use android:textStyle and android:textSize attributes to style TextViews.
Then you will need to call setText() method in respective dialog class to show the results in value TextView. For instance:
<TextView
android:id="#+id/keyTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true"
android:layout_marginTop="5dp"
android:text="Signal Strength"
android:textSize="15sp" />
<TextView
android:id="#+id/valueTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/keyTextView"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:text="Excellent"
android:textColor="#android:color/black"
android:textSize="16sp"
android:textStyle="bold" />

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

Android TextView Not Wraping up the text for hindi text

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

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