android - Set icon on button center position through programatically -


enter image description here

i want set icon on button on center place through programatically above diagram please 1 me...

may helps you..

set background image button in drawable folder use below code:

btn.setbackgroundresource(r.drawable.image); 

or

btn.setbackgrounddrawable(getresources().getdrawable(r.drawable.image)); 

or use: setcompounddrawablewithintrinsicbounds().

look more regarding setcompounddrawablewithintrinsicbounds() in documentation : click here

edit:

try way: setcompounddrawablewithintrinsicbounds(r.drawables.minus,0,0,0);

add line in xml: android:paddingleft="100dp"


Comments

Popular posts from this blog

javascript - Count length of each class -

What design pattern is this code in Javascript? -

hadoop - Restrict secondarynamenode to be installed and run on any other node in the cluster -