setScaleX/setScaleY 是怎么回事?
在尝试为我想要的布局找到解决方案时,我遇到了 setScaleX/setScaleY 方法,它们是 View 类的成员。
现在看看RelativeLayout 和按API级别8进行过滤,因为我正在开发> = 2.2的应用程序,所以上述方法逐渐消失。但是,当查看“从 android.view.View 类继承的 XML 属性”时,属性 android:scaleX/android:scaleY 仍然可用。不幸的是,尝试使用这些属性不起作用,Eclipse 说:“错误:在包'android'中找不到属性'scaleX'的资源标识符”
所以看起来文档是矛盾的,scaleX/scaleY 直到 3.0 才可用,还是我错过了什么?
While trying to find a solution for the layout that I want, I came across the setScaleX/setScaleY methods, which are members of the View class.
Now looking at the methods of RelativeLayout and filtering by the API Level 8, since I'm developing an App for >= 2.2, the said methods fade out. But when looking at "Inherited XML Attributes From Class android.view.View" the properties android:scaleX/android:scaleY are still available. Unfortunately trying to use these properties doesn't work and Eclipse says: "error: No resource identifier found for attribute 'scaleX' in package 'android'"
So it seems like the documentation is contradictory and scaleX/scaleY are not available until 3.0 or am I missing something?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(6)
不,文档是正确的:
Froyo 是 API 级别 8。
nope, the Docs are right:
Froyo is API Level 8.
NineOldAndroid
已弃用,根据其 github 链接 NineOldAndroid使用
Android 支持库
而不是NineOldAndroid
,因此您应该使用
ViewCompat
而不是ViewHelper
只需将:
或
更改为:
希望有帮助
NineOldAndroid
is deprecated according to it's github link NineOldAndroidUse
Android Support library
instead ofNineOldAndroid
so you should use
ViewCompat
instead ofViewHelper
simply change:
or
to:
hope it helps
对于较旧的 API,请使用
com.nineoldandroids.view.ViewHelper
:Use the
com.nineoldandroids.view.ViewHelper
for older APIs:对于任何感兴趣的人:我只放大到画布中心,此代码对我有用:
For anyone interested: I only zoom in to center of canvas and this code works for me:
当我尝试在播放任何动画之前设置具有初始scaleX值的视图时,我遇到了类似的问题,但是view.setScaleX()是自API级别11起根据@Dr.J。
如果您想在早期 API 级别中使用 Honeycomb 动画 API,请尝试使用 http://nineoldandroids.com/ 上的 NineOldAndroids。基于此开源库,有一种解决方法可以为视图提供初始scaleX。
I met a similar problem when I tried to set the view with an initial scaleX value before playing any animations, however view.setScaleX() is since API Level 11 accroding to @Dr.J .
If you want to use the Honeycomb Animation API in earlier API Levels, do have a try with NineOldAndroids at http://nineoldandroids.com/ . Based on this opensource lib, there is a workaround to provide the view an initial scaleX.
好的,看起来这是文档中的错误表示,正如它所解释的 这里的scaleX/scaleY是使用Honeycomb添加到View类中的属性,因此遗憾的是在Froyo中不可用。
Ok, it looks like this is a false representation in the docs, as it's explained here scaleX/scaleY are properties added to the View class with Honeycomb and therefore unfortunately not available in Froyo.