Android ImageButton with LayerDrawable Image -
i'm trying display layerdrawable imagebutton image. layers must have different top values. such top += 10;
. used setlayerinset
drawable layer items stretched images. tried different parameters , displayed other stupid layouts.
after setlayerinset attempt used insetdrawable, giving top parameter own constructor:
new insetdrawable(resources.getdrawable(r.drawable.soldier), 0, layertop, 0, 0);
this time, tops ok, imagebutton displays small area of it.
basic layout, let image,
*---* | | | | ---
the layout should be,
*---* | | *---* | | *---* | | *---* | | | | ---
i set android:scaletype="fitstart"
, changed line below , working charm.
new insetdrawable(resources.getdrawable(r.drawable.soldier), 0, layertop,0,-layertop);
now have more questions,
first, can see creating new instance every layers. if create 1 drawable
object , set every items of array used creating layerdrawable
, use layerdrawable.setlayerinset
function set top , bottom properties, more efficient.
and other 1 if layerdrawable object has more items bigger imagebutton still displays images. there setting such css overflow:hidden
or something?
thanks.
Comments
Post a Comment