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 ...
Related
I seem to have quite a specific problem. I have two tablets, one runs on Android 6.0.1, the other on 5.1.1.
I have an activity and a fragment (the fragment is located on an activity). Each has an EditText element with the following layout:
<EditText
android:id="#+id/etInputForm_1_1"
android:layout_width="250dp"
android:layout_height="30dp"
android:layout_below="#id/tvDescription_1"
android:layout_centerHorizontal="true"
android:layout_marginTop="20dp"
android:cursorVisible="true"
android:imeOptions="actionNext"
android:paddingBottom="5dp"
android:paddingLeft="5dp"
android:paddingStart="5dp"
android:textColor="#color/Black"
android:textSize="15sp"/>
The problem is, if I test it on the device with Android 6.0.1, everything seems to be ok, I can input text wherever I want to, however on the device with 5.1.1, the EditText in the fragment always seems to be empty no matter how many letters I type (the EditText in the activity still works fine).
But the logs still show that the text IS there (however we can't see it).
Anyone had similar problem and a solution to this?
I had a similar issue where the edit text hint wouldn't go away (representing text was in the field) and no text would show up when I was typing but my logs showed text was indeed in the field. I also had an issue where my spinners would not show the selected option
I solved it by enabling hardware acceleration for my application. Since it is enabled by default (I believe) I removed this line from my <application></application> section of my manifest file: android:hardwareAccelerated="false"
My issue resolved after removing following line from edit text.
android:textAllCaps="true"
The problem was resolved by using android.app.Fragment instead of android.support.v4.app.Fragment. Seems that the support fragment class is buggy when using on tablets with Android 5.1.1.
I'm developing an Android application in which I have an EditText control.
I've set the gravity to right, in order to type in Persian.
But when I try to select a text (which is in Persian), the select pointers won't appear.
It works almost fine when the gravity is not set. Also it works fine in other devices like Samsung. But it doesn't work on HTC devices (HTC One xl in my case).
This is my EditText xml
<EditText
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="#+id/txtShare"
android:layout_weight="1"
android:enabled="true"
android:inputType="text|textMultiLine"
android:hint="#string/typeHere"
android:gravity="right"/>
Does anyone know how to fix this?
Edit 1
Also the cursor is always at the beginning of the lines, no matter where I tap in the text.
Edit 2
I'm almost sure that if I can solve the problem in Edit 1, the first problem will be solved along with it. Cause wherever I click in text, the cursor would remain in the beginning of the line
Try adding following attribute to your EditText
android:ellipsize="end"
If you are using right-to-left text you should use the textDirection property for correct support. Gravity only aligns text, so text you enter would still be left-to-right.
The cursor selection is handled in the onTouchEvent method.
I don't have any HTC device, so just an idea.
Maybe you can try to find the problem from the onTouchEvent method.
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.
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 am seeing a weird bug in my app and I was wondering if someone could help me fix it. I have a simple EditText with some existing Text, if I move the cursor to the top and hit the Enter key it moves the first line down and on top of the second line. I made a video to help with the visual of what I am seeing:
https://www.youtube.com/watch?v=vJfTDjBxdT4&feature=youtube_gdata_player
The phone is a stock Samsung Galaxy Nexus. I have tried to change the InputType to various other things but they all see to have the same issue. Here is the layout:
<EditText
android:id="#+id/editor_text"
android:layout_width="fill_parent"
android:layout_height="0dip"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_weight="0.72"
android:gravity="top"
android:inputType="textMultiLine|textCapSentences|textAutoCorrect"
android:singleLine="false" >
</EditText>
This is a Jelly Bean issue with Hardware Acceleration here is the Google link:
http://code.google.com/p/android/issues/detail?id=38770
I verified that using the Software layer fixed the issue for me.