Text skips the last few pixels

I am writing an Android application and sometimes the last few pixels of the text are truncated. This happens on several different controls in different parts of the application. This happens both on the emulator and on my phone.

The following is part of the layout, I added background colors so you can see that the parent layout is full-length, but the text view does not properly encircle the context enter image description here

After the "r" at the bottom, there is obviously a space, but the "a" at the top is slightly truncated. Here is the layout

<LinearLayout android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="wrap_content" android:gravity="center" android:layout_gravity="center" android:background="#fbff18"> <TextView android:id="@+id/SongRowSongName" android:gravity="left" android:layout_gravity="left" android:ellipsize="end" android:maxLines="1" android:singleLine="true" android:layout_width="wrap_content" android:layout_height="wrap_content" android:background="#ff1217"/> <TextView android:id="@+id/SongRowArtistName" android:gravity="left" android:layout_gravity="left" android:ellipsize="end" android:maxLines="1" android:singleLine="true" android:layout_width="wrap_content" android:layout_height="wrap_content" android:linksClickable="false" android:background="#ff1217" android:clickable="false"/> </LinearLayout> 

I know that I can just set the width to full_parent in the textview, but this is just one instance of the problem, and I don’t understand why I need it. Another major place that this happens is in my herd. enter image description here

 intent = new Intent().setClass(this, ProfileActivity.class); spec = tabHost.newTabSpec("profile").setIndicator("Profiles", res.getDrawable(R.drawable.ic_tab_profile)) .setContent(intent); tabHost.addTab(spec); 

and this is what I use as a background image selector

 <?xml version="1.0" encoding="utf-8"?> <selector xmlns:android="http://schemas.android.com/apk/res/android"> <!-- When selected, use grey --> <item android:drawable="@drawable/profile_grey" android:state_selected="true" /> <!-- When not selected, use white--> <item android:drawable="@drawable/profile_white" /> </selector> 

I just have nothing to explain why, when there is a lot of space in the parent, it does not finish the content correctly.

+6
source share
2 answers

For me, the problem was setting up AndroidManifest:

 <supports-screens android:anyDensity="false"> 

After realizing this problem, I found out that the documentation clearly states: "For applications that support Android 1.6 (API level 4) and higher, this is true by default, and you should not set it to false if you’re not sure that it is necessary for your application to work. "

http://developer.android.com/guide/topics/manifest/supports-screens-element.html#any

0
source

Turns out the problem was that I didn't specify minSdkVersion in AndroidManifest.

 <uses-sdk android:minSdkVersion="4"/> 

If I have nothing, I have minSdkVersion <= 3, then the problem arises.

Greetings to all

+1
source

Source: https://habr.com/ru/post/946834/


All Articles