Bug 10544 - TextView resize being clipped
Summary: TextView resize being clipped
Alias: None
Product: Android
Classification: Xamarin
Component: BCL Class Libraries ()
Version: 4.6.x
Hardware: Macintosh Mac OS
: Normal normal
Target Milestone: ---
Assignee: Bugzilla
Depends on:
Reported: 2013-02-21 13:16 UTC by Paul Johnson
Modified: 2013-12-05 18:35 UTC (History)
3 users (show)

Is this bug a regression?: ---
Last known good build:

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.

Please create a new report on Developer Community or GitHub with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:

Description Paul Johnson 2013-02-21 13:16:36 UTC
I have a TextView set into a relativelayout with an image to one side. I am trying to resize the font in the textview so that it will always fit on screen. The code I'm using is this

public static void fontSizeInfo(Context context)
            int imageSizeX = 0;
            using (BitmapFactory.Options opt = new BitmapFactory.Options())
                opt.InJustDecodeBounds = true;
                BitmapFactory.DecodeResource(context.Resources, Resource.Drawable.headerlogo, opt);
                imageSizeX = opt.OutWidth + (int)convertDpToPixel(12f, context);
            float sizeLeft = (float)wowZapp.LaffOutOut.Singleton.ScreenXWidth - (float)imageSizeX;
            if (sizeLeft < 0)
            Paint paint = new Paint(PaintFlags.AntiAlias);
            paint.TextSize = convertDpToPixel((float)Header.fontsize, context);
            float width = paint.MeasureText(Header.headertext);
            System.Diagnostics.Debug.WriteLine("width = {0}, sizeLeft = {1}, textSize = {2}", width, sizeLeft, paint.TextSize);
            while (width >= sizeLeft)
                Header.fontsize -= convertDpToPixel(1f, context);
                paint.TextSize = convertDpToPixel((float)Header.fontsize, context);
                width = paint.MeasureText(Header.headertext);
                #if DEBUG
                System.Diagnostics.Debug.WriteLine("new width = {0}", width);

            Console.WriteLine("Header.fontsize = {0}", Header.fontsize);
            /*if (sizeLeft < width) {
				width -= convertDpToPixel (.5f, context);
				paint.TextSize = width;
				width = convertDpToPixel (paint.MeasureText (Header.headertext), context);
				#if DEBUG
				System.Diagnostics.Debug.WriteLine ("new width = {0}", convertDpToPixel (width, context));

convertDpToPixel does just that.

The code works (the font size is reduced), but the text is truncated despite there being sufficient room on screen. The TextView properties are match_parent for width. In the designer, the text is all on screen using a the default 4" WVGA Nexus S setting.
Comment 1 Jonathan Pryor 2013-07-08 23:11:40 UTC
Is this a binding bug or an Android "bug"?

Rephrased: if you do the same thing in Java, do you get the same behavior? If Java does the same thing as your C# code, then this will be closed as UPSTREAM (it's an Android issue). If this doesn't happen in Java, this is presumably some form of binding bug.
Comment 2 Paul Johnson 2013-07-09 04:06:40 UTC
From what I've been told from a friend who writes for Android in that mess better known as Java, it doesn't happen on there. I don't know enough Java to know if does or doesn't to verify this, so I'm assuming it's a binding issue
Comment 3 PJ 2013-11-19 17:04:51 UTC
This bug has been in the NEEDINFO state with no changes for the last 90 days. Can we put this back into the NEW or CONFIRMED state, or are we still awaiting response?

If there is no change in the status of this bug over the next two weeks, this bug will be marked as NORESPONSE.
Comment 4 PJ 2013-12-05 18:35:01 UTC
This bug has not been changed from the NEEDINFO state since my previous comment, marking as RESOLVED NORESPONSE.

Please feel free to REOPEN this bug at any time if you are still experiencing the issue. Please add the requested information and set the bug back to the NEW (or CONFIRMED) state.