button或者imageview,imagebutton按下的时候变小,松开后还原   这样一个效果怎么做啊?????

解决方案 »

  1.   

    1.在程序中修改onTouch事件,down的时候变小,up的时候还原。
    2.在res/drawable中加入style
    <?xml version="1.0" encoding="utf-8"?>
    <selector
      xmlns:android="http://schemas.android.com/apk/res/android">
        <item android:state_pressed="true" android:drawable="@drawable/btn_bian_black_press" />
        <item android:state_selected="true" android:drawable="@drawable/btn_bian_black_press" />
        <item android:state_focused="true" android:drawable="@drawable/btn_bian_black_press" />
        <item android:drawable="@drawable/btn_bian_black_normal" />
    </selector>
    btn_bian_black_normal普通状态下的图片 
    btn_bian_black_press按下后的图片
    然后imagebutton中src = "@drawable/xxx"
      

  2.   

    关键是activity代码中怎么变小变大?????况且按你这么写的item不管图片大小都是铺满了imageview,
      

  3.   

    上面的不是说了吗,修改onTouch事件,down和up直接改变button的height和width
      

  4.   


    请给出具体的修改高度和宽度的代码,,,ok???我要知道的是怎么设置height和width,,代码里能设置这个吗?????????????!!!!!!!!!!!!!!!!!
      

  5.   


    LinearLayout.LayoutParams layoutParams=new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT,LinearLayout.LayoutParams.WRAP_CONTENT);
    layoutParams.height=50;
    layoutParams.width=50;
    button.setLayoutParams(layoutParams);按照这种思路试试