How to scale and modify the position of ImageButton dynamically?
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
精彩评论