开发者

How to scale and modify the position of ImageButton dynamically?

开发者 https://www.devze.com 2023-02-11 00:12 出处:网络
I create an ImageButton on main.xml. And I want to scale the size and modify the position of ImageButton on the View.

I create an ImageButton on main.xml. And I want to scale the size and modify the position of ImageButton on the 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"
/>

I will set the size - iwidth and i开发者_开发技巧height when user click the button - Next and Prev.

Next button pressed.

                iHeight++;
                iWidth++;
                BtnExplore.setMaxHeight(iHeight);
                BtnExplore.setMaxWidth(iWidth);
                BtnExplore.invalidate();
                BtnExplore.postInvalidate();

Prev button pressed.

                iHeight--;
                iWidth--;
                BtnExplore.setMaxHeight(iHeight);
                BtnExplore.setMaxWidth(iWidth);
                BtnExplore.invalidate();

I still can't scale the imagebutton. I also need how to change the position.

Here is the complete code. http://dl.dropbox.com/u/2452511/AndroidAP/IconClickTest-stackoverflow.tar.gz


Use setMinimumHeight and setMinimumWidth

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号