安卓4.2的Nexus 7:canvas.drawText()无法正常工作

编程入门 行业动态 更新时间:2024-10-26 20:22:23
本文介绍了安卓4.2的Nexus 7:canvas.drawText()无法正常工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我面对我的应用程序的一个严重问题,发表了关于谷歌播放,显然,除了> 4.0做工精细上的所有版本的Andr​​oid。

这是从我的Andr​​oid 4.0的HTC手机screenshoot:

这是我得到的Nexus 7,Android的4.2.1(模拟器中的相同的行为):

我看到相同的行为使用绘制每个文本 canvas.drawText()

用于绘制文本的涂料是:

颜料=新的油漆(); paint.setAntiAlias​​(真正的); paint.setColor(颜色); //一些色彩 paint.setTextSize(大小); //一些大小 paint.setTypeface(Typeface.defaultFromStyle(Typeface.BOLD)); paint.setTextAlign(Align.CENTER);

在LogCat中(4.2.1仿​​真器),我看到了很多

12-18 20:42:21.096:W /跟踪(276):从nativeGetEnabledTags意外的值:0

我在清单中使用这些设置:

<使用-SDK         安卓的minSdkVersion =8         机器人:targetSdkVersion =8/>

解决方案

我很多谷歌上搜索后,回答我的问题...

诀窍包括在使用 setLinearText(真) 作为用于绘制文本的绘制对象。现在,一切看起来不错。

颜料=新的油漆(); paint.setAntiAlias​​(真正的); paint.setColor(颜色); paint.setTextSize(大小); paint.setTypeface(Typeface.defaultFromStyle(Typeface.BOLD)); paint.setTextAlign(Align.CENTER); paint.setLinearText(真正的);

下面,节省了我一天的链接:

gc.$c$chum/p/android/issues/detail?id=39755

我希望它可以帮助someonelse。

该文本不是在最好的呈现尚未:

编辑(14/01/2013)

我仍面临(仅限于4.2.1)一开云集团的问题。请看看我其他的问题在这里:

Android 4.2.1错误的字符字距(间距)

编辑(2013年5月2日)

我看到另外一个项目有同样的问题。看看下面的链接:

mindtherobot/blog/272/android-custom-ui-making-a-vintage-thermometer/

如果您运行的Nexus 4.2.1样品(或模拟器的Andr​​oid 4.2),你会得到相同的奇怪的文字...

编辑(20/02/2013)

找到一个解决方法,不使用 setLinearText(真),看这里:

Android 4.2.1错误的字符字距(间距)

I'm facing a serious issue with my Application, published on Google Play and apparently working fine on all versions of Android except for > 4.0.

This is a screenshoot from my Android 4.0 HTC phone:

And this is what I get on Nexus 7, Android 4.2.1 (same behaviour in the emulator):

I see the same behaviour for each text drawn using canvas.drawText()

the Paint used to draw text is:

paint = new Paint(); paint.setAntiAlias(true); paint.setColor(color); //some color paint.setTextSize(size); //some size paint.setTypeface(Typeface.defaultFromStyle(Typeface.BOLD)); paint.setTextAlign(Align.CENTER);

In the logCat (4.2.1 emulator) I see a lot of

12-18 20:42:21.096: W/Trace(276): Unexpected value from nativeGetEnabledTags: 0

I use these settings in the manifest:

<uses-sdk android:minSdkVersion="8" android:targetSdkVersion="8" />

解决方案

I answer my own question after a lot of googling...

The trick consist in the use of setLinearText(true) for the Paint object used for drawing the text. Now, everything looks great.

paint = new Paint(); paint.setAntiAlias(true); paint.setColor(color); paint.setTextSize(size); paint.setTypeface(Typeface.defaultFromStyle(Typeface.BOLD)); paint.setTextAlign(Align.CENTER); paint.setLinearText(true);

Here the link that saves my day:

gc.codehum/p/android/issues/detail?id=39755

I hope it can help someonelse.

The text is not rendered at the best yet:

Edited (14/01/2013)

I'm still facing a kering problem (only on 4.2.1). Please see my other question here:

Android 4.2.1 wrong character kerning (spacing)

Edited (05/02/2013)

I see another projects has the same problem. Look at the link below:

mindtherobot/blog/272/android-custom-ui-making-a-vintage-thermometer/

If you run the sample on Nexus 4.2.1 (or in the simulator Android 4.2) you get the same "strange" text...

Edited (20/02/2013)

Found a workaround that not uses setLinearText(true), look here:

Android 4.2.1 wrong character kerning (spacing)

更多推荐

安卓4.2的Nexus 7:canvas.drawText()无法正常工作

本文发布于:2023-11-27 10:05:01,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1637624.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:无法正常   工作   Nexus   drawText   canvas

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!