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

c# - SelectList with Dictionary, add values to the Dictionary after it's assigned to SelectList -

how can i manage url using .htaccess in php? -

ios - I get the error Property '...' not found on object of type '...' -