2012-02-16 75 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