java - Set a drawable drawn programmatically on top of the ImageView -


i have drawable , want drawn above imageview. it's not: drawable below imageview

i set on framelayout way:

bubbledrawable bubbledrawable = new bubbledrawable(true); bubblelayout.setbackgrounddrawable(bubbledrawable); 

but doesn't help. neither helped this:

bubblelayout.bringtofront(); bubblelayout.invalidate(); bubblelayout.requestlayout(); 

i tried answer here no use - imageview showed nothing https://stackoverflow.com/a/16370226/3937738

the drawable:

package com.example.chat.view;  import android.graphics.canvas; import android.graphics.color; import android.graphics.colorfilter; import android.graphics.matrix; import android.graphics.paint; import android.graphics.path; import android.graphics.pixelformat; import android.graphics.rect; import android.graphics.rectf; import android.graphics.drawable.drawable; import android.util.log;  public class bubbledrawable extends drawable {    private paint mpaint;    private float mboxwidth;   private float mboxheight;   private rect mboxpadding = new rect();    private float mpointerwidth;   private float mpointerheight;   private boolean my;   private float strokewidth;   private int strokecolor;   private int fillcolor;   private static final string tag = "bubbledrawable";    public bubbledrawable(boolean my) {     this.my = my;     initbubble();   }    private void initbubble() {     setpointersizes(25);   }    @override   public void draw(canvas canvas) {     log.d(tag, "draw");     mpaint = new paint();     mpaint.setantialias(true);     fillbubble(canvas);     drawbubblestroke(canvas);     //drawtriangle(canvas, my);   }    private void drawbubblestroke(canvas canvas) {     mpaint.setstyle(paint.style.stroke);     mpaint.setstrokewidth(strokewidth);     //mpaint.setcolor(strokecolor);     mpaint.setcolor(color.red);     drawpath(canvas);   }    private void fillbubble(canvas canvas) {     mpaint.setstyle(paint.style.fill);     mpaint.setcolor(fillcolor);     drawpath(canvas);   }    private void drawpath(canvas canvas) {     rect bounds = getbounds();     path path = new path();      //right arrow     path.moveto(mboxwidth, mboxheight / 2 - mpointerwidth / 2);     path.lineto(mboxwidth + mpointerheight, mboxheight / 2);     path.lineto(mboxwidth, mboxheight / 2 + mpointerwidth / 2);      //right vertical lower line.     path.lineto(mboxwidth, mboxheight - mpointerwidth / 2);      //bottom right arc.     path.arcto(new rectf(mboxwidth - mpointerwidth, bounds.bottom - mpointerwidth, mboxwidth, bounds.bottom), 0, 90);      //bottom horizontal line.     path.lineto(mpointerwidth / 2, mboxheight);      //bottom left arc.     path.arcto(new rectf(0, mboxheight - mpointerwidth, mpointerwidth, mboxheight), 90, 90);      //left vertical line.     path.lineto(0, mpointerwidth);      //top left arc.     path.arcto(new rectf(0, 0, mpointerwidth, mpointerwidth), 180, 90);      //top horizontal line     path.lineto(mboxwidth - mpointerwidth / 2, 0);      //top right arc     path.arcto(new rectf(mboxwidth - mpointerwidth, 0, mboxwidth, mpointerwidth), 270, 90);      //right vertical upper line.     path.lineto(mboxwidth, mpointerwidth / 2);      path.close();     path.setfilltype(path.filltype.even_odd);     if(!my)       rotatepath(path);     canvas.drawpath(path, mpaint);   }    private void rotatepath(path path) {     matrix mmatrix = new matrix();     rectf bounds = new rectf();     path.computebounds(bounds, true);     mmatrix.postrotate(180, bounds.centerx(), bounds.centery());     path.transform(mmatrix);   }    @override   public int getopacity() {     return pixelformat.opaque;   }    @override   public void setalpha(int alpha) {     // todo auto-generated method stub   }    @override   public void setcolorfilter(colorfilter cf) {     // todo auto-generated method stub   }    @override   public boolean getpadding(rect padding) {     log.d(tag, "getpadding " + padding.bottom + ", " + padding.top);     padding.set(mboxpadding);      return true;   }    @override   protected void onboundschange(rect bounds) {     mboxwidth = bounds.width() - mpointerheight;     mboxheight = getbounds().height();     super.onboundschange(bounds);   }    public void setpointersizes(int pointerwidth) {     mpointerwidth = pointerwidth;     mpointerheight = (float) math.sqrt((double) (pointerwidth * pointerwidth / 2)); //  base of equilateral triangle     log.d(tag, "mpointerheight " + mpointerheight);   }    public void setpadding(int left, int top, int right, int bottom) {     log.d(tag, "setpadding");     mboxpadding.left = left;     mboxpadding.top = top;     mboxpadding.right = right;     mboxpadding.bottom = bottom;   }    public void setpointersizes(int pointerwidth, int pointerheight) {     mpointerwidth = pointerwidth;     mpointerheight = pointerheight;   }    public void setfillcolor(int fillcolor) {     //log.d(tag, "setfillcolor");     this.fillcolor = fillcolor;   }    public void setstrokecolor(int strokecolor) {     this.strokecolor = strokecolor;   }    public void setstrokewidth(float strokewidth) {     this.strokewidth = strokewidth;   } } 

part of layout:

    <imageview         android:id="@+id/image"         android:layout_width="wrap_content"         android:layout_height="wrap_content"         android:paddingright="5dp"         android:adjustviewbounds="true"         android:scaletype="centercrop"/>  </framelayout> 

maybe create 2 imageview in xml file inside relativelayout , position 1 on top of other.


Comments

Popular posts from this blog

ruby - Trying to change last to "x"s to 23 -

jquery - Clone last and append item to closest class -

css - Can I use the :after pseudo-element on an input field? -