如何测试 ScaleType?
有没有办法测试 ScaleType?我在想一些类似的事情:
public View makeView() {
ImageView i = new ImageView(this);
i.setScaleType(ScaleType.FIT_XY);
}
i.setOnTouchListener(new OnTouchListener() {
public boolean onTouch(View v, MotionEvent event) {
ImageView i = (ImageView) v;
switch (event.getAction() & MotionEvent.ACTION_MASK) {
case MotionEvent.ACTION_DOWN:
if (i.setScaleType() == FIT_XY){
...
}
}
不确定这在语法上是否可能。期待您的建议。本质上,我试图做的只是在scaleType!= FIT_XY...时启用拖动(通过开关/案例)...
Is there a way to test for ScaleType? I was thinking something along the lines of:
public View makeView() {
ImageView i = new ImageView(this);
i.setScaleType(ScaleType.FIT_XY);
}
i.setOnTouchListener(new OnTouchListener() {
public boolean onTouch(View v, MotionEvent event) {
ImageView i = (ImageView) v;
switch (event.getAction() & MotionEvent.ACTION_MASK) {
case MotionEvent.ACTION_DOWN:
if (i.setScaleType() == FIT_XY){
...
}
}
Not sure if this is syntactically possible. Looking forward to your suggestions. What i'm attempting to do, essentially, is only enable drag (via the switch/case) if scaleType != FIT_XY...
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
ImageView 也有一个 getScaleType() 方法。这将返回给你我所假设的类型。
这应该会给你你想要的行为。
另请查看 ImageView 的 Javadoc
ImageView has a getScaleType() method too. That will return to you the type I would assume.
This should give you the behavior your looking for.
Also check out the Javadoc for ImageView