I am using accented letters in android textview but on some devices letters are not positioned as expected here is screen shot of two different devices first sony xperia c
which is correct but in LG nexus 4 e960 accented a is not positioned correctly see below screen
textview code in xml
<com.driver.test.widget.CustomTextView
android:id="#+id/text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_marginTop="100dp"
android:gravity="center"
android:text="¿Ya estás \nmatriculado \nen alguna \nautoescuela?"
android:textColor="#color/white"
android:textSize="30sp"/>
How to tackle this issue ?
Have you tried using the next properties?
android:lines="4"
android:lineSpacingExtra="2dp"
That may be the problem..
Related
I have below layout in my xml which will contain 3 TextView and they are aligned left, centre and right respectively.
<RelativeLayout
android:id="#+id/relRow1"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:text="#string/contact"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:text="#string/colon"
android:id="#+id/colonRow1"/>
<TextView
android:id="#+id/txtPrimaryContact"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_toEndOf="#+id/colonRow3"
android:layout_toRightOf="#+id/colonRow3"
android:ellipsize="end"
android:gravity="end"
android:maxLines="1"
android:text="Joe SmithMartinWilliamCathcsdsdsdadas"/>
</RelativeLayout>
The problem I am facing now is that, the ellipsize doesn't go well or work as expected with android device version < 6.0. I mean for device with Marshmallow version, the ellipsize is breaking the text once max width is reached, but for devices having lollipop or kitkat version, may be lower too, the ellipsize breaks down after space in text and displays ellipses, it does not break for long text.
Here is how it looks in android version less than Marshmallow:
Consider the name is FName LName
Contact : FName...
Here is how it looks in android version greater than Marshmallow:
Contact : FName LNa...
Is this a bug in lower versions or expected behavior. Or is there any other way to do this? I would like to have the Marshmallowversion text in all the devices. Anyway I can achieve this?
Update
Turns out, my assumption was wrong after #Charu's comment. It actually hides out for long text in device version < Marshmallow. How can I come over this?
Right now I've been using below code, but that doesn't scale up when we check with different devices with different screen size. I've attached screenshots for reference.
if(android.os.Build.VERSION.SDK_INT<Build.VERSION_CODES.M && name.length()>20)
name=name.substring(0,20)+"...";
else
txtPrimaryContact.setEllipsize(TextUtils.TruncateAt.END);
>=Marshmallow device
< Marshmallow device [Kitkat to be specific but tested in Lollipop too]
You might tell me that android:singleLine="true" is kind of deprecated that's why you used android:maxLines="1" but trust me adding this android:singleLine="true" to your textView should fix the issue!
here is some code, I can replicate the bug even if I strip everything down to a simple TextView.
<TextView
android:layout_width="250dp"
android:layout_height="wrap_content"
android:ellipsize="middle"
android:singleLine="true"
android:text="I AM VERY SMART I AM VERY SMART I AM VERY SMART"
android:textSize="16sp">
</TextView>
I wish I could post a screenshot but SE is not letting me. what happens is that the text is truncated in the middle (as intended) but with a single dot (.) rather than a full ellipsis (...)
it does this on all lollipop tablets that I own (nexus 7 and nexus 9). other devices are displaying the ellipsis properly. I have researched the issue and found various comments about people getting the same problem, but no answers.
I have the same problem as same as you.
I achieved my goal by setting:
width="85dp"
maxWidth="85dp" // same as above
maxLines="1"
Try this:
<TextView
android:layout_width="250dp"
android:layout_height="wrap_content"
android:ellipsize="middle"
android:singleLine="true"
abdroid:focusable="true"
android:focusableInTouchMode="true"
android:text="I AM VERY SMART I AM VERY SMART I AM VERY SMART"
android:textSize="16sp">
</TextView>
I have some RTL text (Hebrew) that I want to be aligned right inside the TextView. Currently the XML looks like this:
<TextView
android:id="#+id/textView2"
android:layout_width="80dp"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:gravity="right"
android:paddingRight="10dp"
android:singleLine="false"
android:textColor="#FFFFFF"
android:textDirection="rtl"
android:textSize="12sp"
android:textStyle="bold" />
And it acually works great on Galaxy S3 Android 4.2.2 and I even tested it on a Galaxy S1 Android 2.3.3 and it was ok too. But on some devices, for example Galaxy S2 Android 2.3.5, it's aligned left for some reason.
I searched alot and I did not find and solution to this problem, I'd be happy if someone will show me a solution within the XML layout file, but programatcly solution can work as well.
I tired with your code.. you want to placed the text in right side of textview right?...
I'm pretty to help you because, I also gone through this issue..
In your code,
android:gravity="right"
Instead of this, try this
android:gravity="end"
I think this is what you are looking for
I have a AutoCompleteTextview when I enter a character then sometimes it leads to Google search screen of android. I dont know y this is so.
Layout Declaration for AutoCompleteTextview is:
<AutoCompleteTextView
android:id="#+id/search_box"
style="#style/AutoSuggestList"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#drawable/bar_search"
android:maxLength="1024"
android:dropDownWidth="match_parent"
android:ellipsize="end"
android:hint="#string/hint_In_searchBar"
android:inputType="text|textNoSuggestions"
android:paddingLeft="11dp"
android:layout_alignParentRight="true"
android:singleLine="true"
>
</AutoCompleteTextView>
There is also a search Icon over this view at right corner.
But only typing a character itself is leading to Google search.
Example image :
(source: fonearena.com)
Device in which I found this issue: Samsung galaxy S, O.S. version : 2.3.4
Please any suggestions for the same.?
I am displaying a Checkbox on a layout xml.
The Checkbox text contain around 10 characters.
The problem is specific to Sony Xperia where the the Checkbox text is coming to the second line , specifically last 2 characters of the text on the second line.
<CheckBox android:id="#+id/roundCheck" android:paddingLeft="25dip"
android:button="#drawable/ic_uncheck_rect" android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:layout_marginLeft="20dip" android:text="abcdefghij"
android:textSize="16sp"
android:textColor="#color/white" android:typeface="serif"
android:singleLine="true" android:checked="false"
android:layout_centerVertical="true"></CheckBox>
I have tested the mobile application on HTC Hero , Google Nexus One , Motorola Droid ,etc , but its working fine without any problem.
The problem is not getting reflected on the Sony Xperia emulator too.
Is adding the code, android:singleLine="true" , solve the issue , if it means that after a certain no of characters "..." will be added but the text will be in a single line ?
I don't have a mobile device to currently test.
Thanks in advance.
Warm Regards,
CB
If I understand you right, then you want the label of your checbox to not have multiple lines. If so you should use android:lines="1" instead of android:singleLine="true", because that is deprecated.
Usually that shouldn't break the behaviour, but I don't know if Sony did some "optimizition" on that ;)
You could also try using android:inputType="text", I'm not quite sure if that would be helpful though...
Hope I understood your problem right ...