Canvas.drawRect()停止更新到Android工作室0.6.0后绘制 [英] Canvas.drawRect() stops drawing after updating to Android Studio 0.6.0

查看:655
本文介绍了Canvas.drawRect()停止更新到Android工作室0.6.0后绘制的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我最近更新我的Andr​​oid应用程序(见Github上 源)使用Android Studio的0.6.0,这需要碰撞集结工具v19.1.0(从v19.0.1),Android的摇篮插件v0.11(0.9),并且摇篮包装到1.12(从1.11)。

I recently updated my Android app (see source on Github) to use Android Studio 0.6.0, which required bumping the build-tools to v19.1.0 (from v19.0.1), the Android Gradle plugin to v0.11 (from 0.9), and the Gradle wrapper to 1.12 (from 1.11).

以上更改之前(rel=\"nofollow\">这在),应用程序已成功绘制正方形画布显示GLONASS卫星的信号强度(见标识87和88):

Before the above changes (at this commit), the app was successfully drawing squares on a canvas to show signal strength of GLONASS satellites (see IDs 87 and 88):

更新我的Andr​​oid的工具,并通过Android的工作室或<$ ​​C $ C> gradlew installDebug 启动后,广场突然消失(见标识77,87,88):

After updating my Android tools and launching via Android Studio or gradlew installDebug, the squares suddenly disappeared (see IDs 77, 87, 88):

在code,吸引了广场上,与中心(X,Y)是:

The code that draws the square, with a center of (x,y), is:

canvas.drawRect(x - SAT_OFFSET, y + SAT_OFFSET, x + SAT_OFFSET, y - SAT_OFFSET, mSatelliteStrokePaint);

(见<一href=\"https://github.com/barbeau/gpstest/blob/master/GPSTest/src/main/java/com/android/gpstest/GpsSkyFragment.java#L332\"相对=nofollow> Github上为满级)

所有的变化承诺更新到Android工作室0.6.0可以看出这里

The commit with all changes to update to Android Studio 0.6.0 can be seen here.

为什么 canvas.drawRect()突然停止更新的Andr​​oid工具后工作?

Why did canvas.drawRect() suddenly stop working after updating the Android tools?

推荐答案

显然,这牵扯到与Android处理无效的输入值的drawRect(),由Android触发摇篮插件0.11 使默认情况下,新的清单合并工具

Apparently this has something to do with Android handling invalid input values for drawRect(), triggered by Android Gradle Plugin 0.11 enabling the new manifest merging tool by default.

如果我想补充 useOldManifestMerger真正我的的build.gradle ,然后平方返回:

If I add useOldManifestMerger true to my build.gradle, then the squares return:

android {
    compileSdkVersion 19
    buildToolsVersion "19.1.0"
    useOldManifestMerger true
    ...
}

根本的问题是, Canvas.drawRect() 发生在参数(左浮动,浮顶,右浮动,浮动底,涂料粉刷)

我有矩形的顶部和底部的坐标反转,所以顶端值(其应该是最小的y值)为较大的y值,和底值(这应该是最大y值)为最小的y值(原点(0,0)在左上角)。

I had the top and bottom coordinates of the rectangle reversed, so the top value (which should have been the smallest y value) was the larger y value, and the bottom value (which should have been the largest y value) was the smallest y value (the origin (0,0) is in the upper left corner).

在Android的工作室0.6.0工具的更新,Android的被纠正无效的输入,还是绘制方形。后,Android工作室0.6.0工具更新开始使用新的清单合并工具,Android是不再纠正无效的输入,而是它不画任何东西。

Before Android Studio 0.6.0 tool updates, Android was correcting invalid input and still drawing the square. After Android Studio 0.6.0 tool update started using the new manifest merging tool, Android is no longer correcting invalid input and instead it doesn't draw anything.

改变我的code扭转后上方/平方的底部y值:

After changing my code to reverse the top/bottom y values of the square:

c.drawRect(x - SAT_OFFSET, y - SAT_OFFSET, x + SAT_OFFSET, y + SAT_OFFSET, mSatelliteStrokePaint);

...的平方(使用新的清单并购即使再度出现 - 即无需添加 useOldManifestMerger真正的build.gradle )。

因此​​,要解决这个问题,正确的方法是扭转广场的顶部/底部坐标是有效的输入,还是使用新的清单合并。

So, the correct way to fix this issue is to reverse the top/bottom coordinates of the square to be valid input, and still use the new manifest merger.

这篇关于Canvas.drawRect()停止更新到Android工作室0.6.0后绘制的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆