1
我在main.xml上創建一個ImageButton。 我想縮放尺寸並在視圖上修改ImageButton的位置。如何動態縮放和修改ImageButton的位置?
main.xml中
<ImageButton
android:id="@+id/BtnExplore"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/btn_320x240_explorer"
android:background="@android:color/transparent"
/>
我設置的大小 - iwidth和IHEIGHT當用戶點擊按鈕 - Next和Prev。
下一個按鈕被按下。
iHeight++;
iWidth++;
BtnExplore.setMaxHeight(iHeight);
BtnExplore.setMaxWidth(iWidth);
BtnExplore.invalidate();
BtnExplore.postInvalidate();
上一個按鈕被按下。
iHeight--;
iWidth--;
BtnExplore.setMaxHeight(iHeight);
BtnExplore.setMaxWidth(iWidth);
BtnExplore.invalidate();
我仍然無法縮放imagebutton。 我還需要如何改變位置。
這裏是完整的代碼。 http://dl.dropbox.com/u/2452511/AndroidAP/IconClickTest-stackoverflow.tar.gz
這是行不通的我測試後。我不確定問題出在哪裏。 setMinimumHeight或invalidate函數有問題嗎? – ccchun 2011-02-18 06:20:37