我的眼睛,我的手指都告诉我不同​​的东西 [英] My eyes and my fingers are telling me different things

查看:208
本文介绍了我的眼睛,我的手指都告诉我不同​​的东西的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我感动编程的几个子视图的布局。子视图所有显示在新的位置。然而,点击触摸事件仍在工作好像观点在他们的老位置。我该怎么办?

I programatically moved a layout with several child views. The child views all display in their new positions. However, the click and touch events are still working as if the views were in their old positions. What do I do?

编辑:

我用翻译比例移动布局。下面是一个类扩展LinearLayout中的code:

I used translate and scale to move the layout. Here is the code from a class extending LinearLayout:

@Override
protected void onDraw(Canvas canvas) {
    canvas.translate(getWidth(), 0);
    canvas.scale(-1, 1);
    super.onDraw(canvas);
}

我在多个活动中使用这种新的布局,但问题是它们都相同。这里是简单布局之一:

I use this new layout in multiple activities, but the issue is the same for all of them. Here is one of the simpler layouts:

<?xml version="1.0" encoding="utf-8"?>
<com.example.myapp.NewLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical" >

    <GridView
        android:id="@+id/chapter_gridview"
        style="@style/GridStyle" />

</com.example.myapp.NewLayout>

任何解决方案?

更新

一种方式可以是更新的LayoutParams,但我不知道该怎么做呢。这是我发现一些相关的问题:

One way may be to update the LayoutParams but I am not sure how to do that yet. These are some related questions I found:

<一个href=\"http://stackoverflow.com/questions/10137657/onclicklistener-issues-after-imagebutton-moved-after-translateanimation\">OnClickListener之后的ImageButton问题TranslateAnimation

<一个href=\"http://stackoverflow.com/questions/6535648/how-can-i-dynamically-set-the-position-of-view-in-android\">How我可以动态地设置来看Android中的位置?

http://www.clingmarks.com/how-to-permanently-move-view-with-animation-effect-in-android/400

修改

没有解决方案?我放弃了呢。

No solutions? I give up then.

推荐答案

如果您正在使用AnimationTranslation工作:
你的LinearLayout已经看似感动,但它只是在视觉上moved.The的LinearLayout仍然是它在哪里动画之前。

If you are working with AnimationTranslation : Your LinearLayout had been moved seemingly,but it's just visually moved.The LinearLayout is still where it is before the animation.

试试这个在您的布局:

mylayout.layout(x,x,x,x);

我把我的答案从这里

I took my answer from here

您还可以看到

修改

EDIT

如果您正在使用Canvas.translate工作:

尝试代替填充翻译: canvas.setPadding(的getWidth(),0);

这篇关于我的眼睛,我的手指都告诉我不同​​的东西的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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