Make an Android button change background on click through XML

后端 未结 5 1636
春和景丽
春和景丽 2020-11-27 02:59

Is there a way to specify an alternative background image/color for a Button in the XML file that is going to be applied onClick, or do I have to do a But

5条回答
  •  执念已碎
    2020-11-27 03:28

    public void methodOnClick(View view){
    
    Button.setBackgroundResource(R.drawable.nameImage);
    
    }
    

    i recommend use button inside LinearLayout for adjust to size of Linear.

提交回复
热议问题