Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Text missing last few pixels

Tags:

android

I am writing an android app and sometime the last few pixels of text is being truncated. It is happening on a few different controls in various parts of the apps. This happens on both the Emulator and on my phone.

Below is part of the layout, I have added background colours so you can see that the parent layout is taking up the full length but the text view isn't wrapping the context correctly enter image description here

After the 'r' at the bottom then is clearly a gap, yet the 'a' on 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 I could just set the width to full_parent on the textview, but this is only one instance of the issue and I dont see why I should have to. The other main place it is happening is in my tabhost. 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 am using as the 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>

It just doesn't make sense to me why when there is plenty of space in the parent does it not wrap content correctly.

like image 542
Jason Avatar asked Jun 08 '13 05:06

Jason


1 Answers

It turns out the issue was because I had not specified a minSdkVersion in the AndroidManifest.

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

If I don't have anything, of have a minSdkVersion of <= 3 then the issue occurs.

Cheers all,

like image 78
Jason Avatar answered Sep 30 '22 19:09

Jason