2012-02-16 96 views
0

我在绝对布局中制作了一些Imagebuttons,然后用它所有的按钮旋转整个布局,现在我有一个问题,即图像按钮的操作不起作用,可能是因为操作不与的ImageButtonImageButton操作不起作用

请,如果有人知道发生了什么事让我知道

main.xml中

<AbsoluteLayout 
    android:id="@+id/wheelLayout" 
    android:orientation="horizontal" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_weight="1" 
    android:layout_x="-250px" android:clickable="true"> 


    <ImageView 
    android:id="@+id/wheelBG" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:src="@drawable/wheel"/> 

    <ImageButton 
     android:id="@+id/accounts" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_x="258dp" 
     android:layout_y="222dp" 
     android:background="@null" 
     android:onClick="accountsOnClick" 
     android:src="@drawable/accounts"/> 

    <ImageButton 
     android:id="@+id/cards" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_x="228dp" 
     android:layout_y="291dp" 
     android:background="@null" 
     android:onClick="cardsOnClick" 
     android:src="@drawable/cards"/> 
</AbsoluteLayout> 

然后我已经做了功能来旋转在一个特定的持续时间

使用RotateAnimation以及角度全绝对布局和我已经定义的按钮

公共无效accountsOnClick(查看视图的动作){ System.out.println(“imageButton1OnClick”); }

循环之前的动作是运作良好,但旋转后的动作不工作

+5

请上传你的代码 – Altaaf 2012-02-16 08:30:56

+0

好吧,你的代码有些奇怪,不是吗? – waqaslam 2012-02-16 08:32:57

+1

仅供参考,AbsoluteLayout **已弃用** – 2012-02-16 08:43:39

回答

0

你应该使用两种不同的布局。开始动画之前的一个和动画完成后可以使用的第二个特殊布局。使用AnimationListener来处理动画完成的事件。然后膨胀一个新的布局,看起来像已经旋转布局。

+0

由于动画是以不同角度随机发生的,我无法处理所有角度,并为每个角度做出不同的布局 – 2012-02-16 09:45:29

+0

其他方式。您可以将View.OnTouchListener用于父视图或整个活动。然后,您可以监听触摸事件并手动计算GUI元素的边框。这太难了,需要很多难看的手工工作。 – 2012-02-17 06:55:47