0

I am using Floating Action Button to show menu. Is it possible to fill the entire circumference including the area of the menu and fab combined with some background color. I want the entire section highlighted to be a some specific color when menu expands. I am able to achieve partial result. In the below photo, how can i i make that yellow portion to be an arc instead of a rectangle. I have tried using drawArc on a canvas to my Framelayout, but it is still giving me a rectangular shaped yellow.

   @Override
protected void onDraw(Canvas canvas) {
    super.onDraw(canvas);
    if(getOpened()) {
        canvas.drawColor(Color.YELLOW);
        Paint p = new Paint();
        // smooths
        p.setAntiAlias(true);
        p.setColor(Color.YELLOW);
        p.setStyle(Paint.Style.FILL);
        p.setStrokeWidth(5);
        // opacity
        //p.setAlpha(0x80); //

        RectF rectF = new RectF(100, 100, 100, 100);
        canvas.drawOval(rectF, p);
        p.setColor(Color.YELLOW);
        canvas.drawArc(rectF, 180, 270, false, p);
    }
}

My iamge

arun
  • 153
  • 1
  • 10
  • please can u share rough sketch of what you want. it will make understand easy and give solution fast – Ashu Kumar Mar 15 '18 at 08:39
  • updated by question with photo – arun Mar 15 '18 at 08:46
  • so u want to change color of entire background color ? – Ashu Kumar Mar 15 '18 at 08:47
  • @AshuKumar yes,when the menu expands. When menu closes, i want to remove that color – arun Mar 15 '18 at 08:48
  • i think you can not change as it is predefined. another solution is you have to create one view behind the fab icon and set width and height of view according to fab icon context menu and show that view when fab icon click and hide when fab icon hides – Ashu Kumar Mar 15 '18 at 08:54
  • Edited my question – arun Mar 16 '18 at 09:05
  • did u try this question answer https://stackoverflow.com/questions/30969455/android-changing-floating-action-button-color?rq=1 – Ashu Kumar Mar 16 '18 at 09:21
  • @AshuKumar The answer there deals with the changing background color of the FAB and not the area i have in yellow. So my requirement doesnt match with the answer at all. – arun Mar 16 '18 at 09:35
  • I am almost done with the requirement, only thing stopping me is that the yellow section should be like a arc and not a rectangle. – arun Mar 16 '18 at 09:39
  • why not use layerlist for creating arc shape, it will let you create any kind of shape you need – Ashu Kumar Mar 16 '18 at 10:15
  • I have used ArcShape class inside onDraw method to get my desired result – arun Mar 16 '18 at 12:06

0 Answers0