如何动态缩放和修改ImageButton的位置?

时间:2011-02-16 09:32:55

标签: android android-widget imagebutton

我在main.xml上创建了一个ImageButton。 我想缩放大小并修改ViewButton在View上的位置。

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();

我仍然无法缩放图像按钮。 我还需要如何改变立场。

这是完整的代码。 http://dl.dropbox.com/u/2452511/AndroidAP/IconClickTest-stackoverflow.tar.gz

1 个答案:

答案 0 :(得分:0)

使用setMinimumHeightsetMinimumWidth