TextView link text is not visible - android

I have a TextView that shows all inserted text except for the links, but the place where they should be is still clickable and takes me to the desired destination. What would be making the link itself invisible?
From string resource
<string name="credits">Video from Youtube</string>
From layout
<TextView
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:background="#color/colorAccent"
android:fontFamily="#font/abril_fatface"
android:lineSpacingExtra="12sp"
android:paddingLeft="16dp"
android:paddingTop="75dp"
android:paddingRight="16dp"
android:text="#string/credits"
android:textAlignment="center"
android:textColor="#color/colorPrimaryDark"
android:textSize="30sp" />
From activity
textCredits.movementMethod = LinkMovementMethod.getInstance()

The cause might be the equality of text color and background. Try to set another color to the links using:
android:textColorLink="#color/someColor"

Use a color like this this
android:textColorLink="#fff"
And
android:autoLink="true"

Related

Linear Layout I can not see Password on page

<TextView
android:id="#+id/textView6"
android:layout_width="76dp"
android:layout_height="25dp"
android:layout_marginStart="35dp"
android:gravity="center"
android:orientation="horizontal"
android:text="Password"
android:textColor="#FFFFFF"
android:textSize="18sp"/>
I can not see Password text on the phone . I can see outside how can ı fix this?
Sorry for eng.
change android:textColor value to #000000. But better to use android:hint instead of android:text. You can also change android:hint color by android:hintColor
Actually the text is there but you can't see it because your text color is the same as the background color (which is white)
So, try changing the text color or changing the background color (or use dark mode to see your text).
If you have a problem with color and you have a single theme, you can combine day and night themes. If the user's Android phone was more than 8, only one theme will work.
I think the bad part
android:layout_height="25dp"
It can be difficult to be seen in phones of different sizes
when u wanna use TextView, try this way for me it's always working.
<TextView android:id="#+id/textView6"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="8dp"
android:gravity="center"
android:text="Password"
android:textColor="#FFFFFF"
android:textSize="12sp"/>
so how you can see u don't need
android:layout_marginStart="35dp"
android:orientation="horizontal"

Android - Resize Text to fit inside a TextView

I'm trying to resize the wrapping text in a TextView to fit within its bounds.
I've created a new class with the source from here and I've added it inside my layout:
<com.util.AutoResizeTextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginLeft="10dp"
android:layout_alignLeft="#id/ivBulb"
android:layout_marginTop="5dp"
android:layout_marginBottom="80dp"
android:layout_below="#id/ivBulb"
android:layout_marginRight="10dp"
android:id="#+id/textP"
android:ellipsize="none"
android:fontFamily="sans-serif"
android:textColor="#000"
android:textSize="100sp"/> <!--maximum size -->
The text that should be displayed inside the TextView is something like:
The sunset filled the entire sky with the deep color of rubies, setting the clouds ablaze. The waves crashed and danced along the shore, moving up and down in a graceful and gentle rhythm like they were dancing.
Some texts can be a multiline but some don't.
My problem is that the text font size is small (about 35dp) and it's always the same :(
I've added a ScrollView in order to be able to display all the text but I want to keep just the TextView and the text to resize
I'm new in Android development so please be gentle.
use from android.support.v7.widget.AppCompatTextView
and set
android:ellipsize="none"
android:singleLine="true"
app:autoSizeMaxTextSize="14sp"
app:autoSizeMinTextSize="12sp"
app:autoSizeStepGranularity="0.5sp"
app:autoSizeTextType="uniform"
in
<android.support.v7.widget.AppCompatTextView
android:ellipsize="none"
android:singleLine="true"
app:autoSizeMaxTextSize="14sp"
app:autoSizeMinTextSize="12sp"
app:autoSizeStepGranularity="0.5sp"
app:autoSizeTextType="uniform"
android:layout_width="match_parent"
android:layout_height="wrap_content" android:id="#+id/txt_ortopedi"
android:textColor="#color/text_color"
android:padding="4dp" android:hint="#string/search"
android:gravity="clip_vertical|center_horizontal" android:layout_gravity="center"
android:background="#color/white"/>

How to make TextView looks exactly like EditText?

How to make the whole TextView underline at the width of match parent like EditText?
This line of code only underlines the text, not the whole TextView.
textView.setPaintFlags(textView.getPaintFlags()| Paint.UNDERLINE_TEXT_FLAG);
The reason I want to use TextView is that setOnClickListener is triggered immediately in one tap for TextView, whereas two taps are required for a disabled editable EditText.
You can put the background of an EditText on your TextView. For example:
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Your text"
android:hint="My hint"
android:textColor="?attr/editTextColor"
android:background="?attr/editTextBackground"
android:gravity="center_vertical"
android:textAppearance="?android:attr/textAppearanceMediumInverse"
/>
You might want to change the text appearance to android:textAppearance="#style/TextAppearance.AppCompat.Button" if you are using an AppCompat theme.
You can achieve this without writing many lines of xml attributes:
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Your text"
android:hint="Your hint"
style="#android:style/Widget.EditText"
/>

Android TextView SingleLine field hides long text

I have a TextView which sits on the left side of the screen and is set with gravity="right" and it is set with SingleLine = "true."
If by some chance the text in this view gets too long I want it to simply disappear off the left hand side of the view. I thought the configuration below would do that but what actually happens is the the long string disappears completely, presumably down and outside of the view somewhere.
How can I create a simple text view that contains a single line of text and keeps its layout even when something unexpected happens? ... or even something predictable.
<TextView
android:id="#+id/tempF"
android:text="#string/tempF"
android:layout_width="146dp"
android:layout_height="wrap_content"
android:textColor="#cccccc"
android:textStyle="bold"
android:textSize="92dp"
android:fontFamily="serif"
android:gravity="right"
android:layout_marginTop="60dp"
android:layout_gravity="top|left"
android:singleLine="true"
/>
This is the purpose of "ellipsize" - truncating a portion of text to indicate additional text.
In you case, you may simply need to add something like:
android:ellipsize="end"
or you might need to go deeper:
Automatically ellipsize a string in Java
Or look at this:
android ellipsize multiline textview
The idea behind extending the class is that you can customize the behavior of the TextView when the text content exceeds the space provided. For example, you can give it the appearance the it "bleeds over" by removing padding, etc. An ellipsis is an indicator that is commonly used to explain "there's more text that you can't see" - this is how it would look:
This is really a really long...
(the 3 periods are the ellipsis - your text goes the opposite direction, but it should still work)
With a custom TextView, you could change the "..." to nothing or anything else you want (even an image, which I've done).
You could also marquee the text:
TextView Marquee not working
Add 2 properties in xml
android:singleLine="true"
android:ellipsize="end"
You should play with ellipsize attribute of the TextView.Check below:
<TextView
android:id="#+id/tempF"
android:text="#string/tempF"
android:layout_width="146dp"
android:layout_height="wrap_content"
android:textColor="#cccccc"
android:textStyle="bold"
android:textSize="92dp"
android:fontFamily="serif"
android:gravity="right"
android:layout_marginTop="60dp"
android:layout_gravity="top|left"
android:singleLine="true"
android:ellipsize="end"
/>
<TextView
android:id="#+id/tv_desc"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#color/colorGray"
android:textSize="#dimen/_18dp"
android:padding="#dimen/_2dp"
android:singleLine="true"
android:ellipsize="end"
android:text="#string/desc" />
Since android:singleLine is deprecated. We can use this line android:maxLines
Can do like this.
android:ellipsize="end"
android:maxLines="1"
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="#000000" />
It works.

How to Align the Text Properly in TextView?

I have a Textview in which i need to show large information in proper format.How can i achieve it?
I want to display like this:
Title : Some Title.
Date : Date
More Info about the title.
......
......
Contact : Contact Details.
Well you have to do it by calculating the space between the options.
The better way
Use a Webview make an html string with contents aligned properly using html formattings and load webview and display it.
If using a TextView is not essential you can use TableLayout:
<TableLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TableRow>
<TextView
android:layout_width="0dip"
android:layout_height="wrap_content"
android:text="Title"
android:layout_weight="1"/>
<TextView
android:layout_width="0dip"
android:layout_height="wrap_content"
android:text="Some Title"
android:layout_weight="2"/>
</TableRow>
<TableRow>
<TextView
android:layout_width="0dip"
android:layout_height="wrap_content"
android:text="Date"
android:layout_weight="1"/>
<TextView
android:layout_width="0dip"
android:layout_height="wrap_content"
android:text="Some Date"
android:layout_weight="2"/>
</TableRow>
</TableLayout>
I think there are three options.
If font doesn't matter use android:typeface="monospace" in your textview and align through spaces
If font does matter design it in html and use a WebView
If you don't want to work with html, you need to make the layout through different TextView's which is imo always better.
As suggested by others, WebView is the option for you. See
How to programmatically set / edit content of webview
However, it is possible to do it in a TextView if the text doesn't need special formatting (ex. different color, font sizes) and the only formatting required is indentation.
In layout:
<TextView
android:id="#+id/text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:singleLine="false" />
In Activity:
TextView tv = (TextView) findViewById(R.id.text);
tv.setText("Title : Some Title.\nDate : Date\n\nMore Info about the title.\n......\n......\n\nContact : Contact Details.");

Categories

Resources