Android TextView autoLink web Bug - android

I have a TextView like this.
<TextView
android:id="#+id/text_auto_linkify"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:autoLink="web"
android:text="#string/link_text_auto" />
and the #string/link_text_auto" like this
<string name="link_text_auto"><b>text_auto_linkify: Various kinds
of data that will be auto-linked.</b>\n
1. In this text are some things that are actionable.\n
1.In this text are some things that are actionable.
</string>
notice the text, that the first one has space after "1."
and the result is out of my expectation.
[1.In this text are some things that are actionable.] Android thinks it's a hyperlink.
so is there anyone can tell me,why?
my phone is Moto X
and the android version is 5.1.1

Related

Android O Text Justification Hebrew

I know there has been A LOT of talk here regarding justifying text in Android. But Android O just came out and a new feature came out with it, Text Justification. They say use the final JUSTIFICATION_MODE_INTER_WORD included with the TextView class. Along with setJustificationMode(). it does work when I use it with the English language, but it fails to work when I use it with the Hebrew language. I have it set up to:
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:justificationMode="inter_word"
android:text="#string/ahahvaRabba"
android:textDirection="rtl"
/>
I also tried to put android:gravity="right" but that didnt work either.
I cant imagine that google didn't think of using it with other languages.

Android - Ellipsize not working for a link in TextView

I'm a newbie to Android and I have looked at similar questions asked by others without a definite answer, since, I think, my problem is a bit different.
I'm using a TextView in my program in which there can be links, text, numbers etc. following is the TextView I'm using.
<TextView
android:id="#+id/viewText"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:paddingBottom="5dp"
android:autoLink="web"
android:linksClickable="false"
android:ellipsize="end"
android:maxLines="7" />
Although this is working for normal texts, the ellipsize does not work whenever links are present in the TextView. I'm using "autoLink" in order to show the user that it is link but had set android:linksClickable to false. Right now, I've added the ellipsize from the code but I want to know whether I can do it from the XML file itself.
Thank you.

Turkish characters don't appear in Android

I have this xml :
<TextView
android:id="#+id/tv_mytv"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
/>
And I have this Java :
TextView mytv;
mytv= (TextView) findViewById(R.id.tv_mytv);
mytv.setText(Html.fromHtml("<p>ğüşçı</p>"));
When I run the emulator, All I get is question marks in diamond shaped icons. How can I make my app display Turkish characters? Thanks.
Check that the charset is set to UTF-8/16 or ISO-8859-9 (Turkish charset). If that doesn't solve the problem, it could be the font itself. Try running the app on a real device to see if it works.
EDIT -
You can also try unicode charecters. For example - http://unicode-table.com/

Samsung Galaxy Tab 3 7.0 Android 4.4.4: TextView Html.fromHtml does not work

I have this code to show green feedback stars in a TextView:
Spanned sp = Html.fromHtml("<font color=\"#00dd00\">★</font>");
tv.setText(sp);
and it works on all devices I've tested beside the one in topic.
I cannot understand why.
A big problem is that the device is not mine and I don't know when I can get it back to test again, so I cannot reproduce the bug.
Another problem is that I've tested a couple of emulators with Android 4.4.4 and I could not find any problem.
Is there another way to show colored text in a safer way ?
Of course the stars are 5 and can be colored in a dynamic way (gray or green) otherwise it would not be a problem.
To be more detailed: if there are 2 green stars, the code is
Spanned sp = Html.fromHtml("<font color=\"#00dd00\">★</font><font color=\"#00dd00\">★</font>");
tv.setText(sp);
because it's created in a loop where <font color=\"#00dd00\">★</font> is a constant.
edit:
This is the definition of the TextView
<TextView
android:id="#+id/txtThumbnail"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginLeft="20dp"
android:layout_marginRight="40dp"
android:ellipsize="end"
android:gravity="center_vertical"
android:maxLines="1"
android:text=""
android:textSize="#dimen/elv_group_thumbnail_text_size"/>
"It does not work" means that the stars are shown but not green so it seems that the html color tag has no effect.
The solution, suggested by #CommonsWare, is to replace the TextView with a RatingBar
I had to create my own star pictures and a selector to handle them but, at the end, all is much simpler.
The proof is that I had to delete code :)
I don't know if this works on the Samsung device as well but I don't think that Samsung has fiddled also with the RatingBar.
As soon as I get the device, I test and post the result but, as far, this is an acceptable solution from my side.

RTL alignment not working with long text

I'm working on a layout that includes both English and Hebrew (intended as right-to-left) text, in separate views. When a line of Hebrew text gets beyond a certain length, it becomes written left-to-right (I assume that this has to do with length because it looks fine with shorter text, and when I display it on a tablet instead of a phone).
The relevant view looks like this:
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:singleLine="true"
android:gravity="center"
android:textDirection="rtl"
android:text="#string/tx_middle_text"
android:textSize="#dimen/big_text_dp" />
and the string is defined in strings.xml like this:
<string name="tx_middle_text">טקסט בעברית</string>
(I've replaced the original text, which was 50 characters long, and made up entirely of Hebrew letters and white-spaces).
Note the text has the rtl attribute. I've tried replacing it with anyRtl, and I've tried changing gravity to "right" - neither helps.
I need the text to remain in one line and be cut off with an ellipsis if it doesn't fit - as it is, that's what happens, but with the text written left-to-right.
How can I fix this?
Edit: For an ad-hoc solution I made a shorter string as an alternative resource for the smaller layout (it works as long as the text is less than one line long on a given device), but I'd still like to know if there's a general solution to this.
RTL is detected automatically by the system depending on the characters. i.e for Arabic characters, text will be drawn from right to left.
This is an example on how my spinner is drawn. For this TextView:
<TextView
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/spinner_item"
android:layout_width="match_parent"
android:layout_height="50dp"
android:textSize="15sp"
android:gravity="center_vertical|start"
android:textColor="#color/spinner_filter_text"
android:ellipsize="end"
android:singleLine="true"
android:paddingStart="20dp"
android:paddingEnd="20dp"/>
And these strings:
<string name="all_categories">All Categories</string> (values)
(values-ar)
The result is:
If I modify the TextView with:
android:layout_width="100dp"
The result is:
Which I think is fine... Note that in strings.xml the string direction for ar language is wrong but Android is drawing it properly. I guess it is because of some Android Studio setting.
Replace android:singleLine="true" with
android:lines="1"
android:maxLines="1"
also add android:ellipsize="end"

Categories

Resources