0

I'm implementing a textview with BubbleMessage Background in Android. I have created the background with a NinePatchDrawable (The image I used).

I want to change the elevation of the textview in the xaml so I set android:elevation="30dp" in the TextView, but after I did this I didn't get the wanted result. The result I got is: Rectangular elevation.

As you can see in the image I get the elevation not on the bubbleMessage itself but on the Rectangle that it is contained in.

I tried the solution that is suggested here but it didn't help.

JackPot16
  • 97
  • 1
  • 1
  • 9
  • then draw the shadow by yourself, what `Drawable` class are you using as your `TextView:background`? – pskink Aug 15 '17 at 12:16
  • I use NinePatchDrawable on this example but I'm having problem using ShapeDrawable as well. With ShapeDrawable I can't see the elevation at all. – JackPot16 Aug 15 '17 at 12:18
  • when you are using a `ShapeDrawable` with a custom `Shape` class you have a free hand and you can draw whatever you want in `draw` method – pskink Aug 15 '17 at 12:23
  • So I should add another drawable with the same shape but with some delta from the original shape? – JackPot16 Aug 15 '17 at 13:38
  • for example, but you could also draw it by yourself like done in this Shape: https://gist.github.com/pskink/fe09aacd259f5cb050aa22691b294f1b – pskink Aug 15 '17 at 13:56
  • I didn't totally understand how to draw it by myself from the code. But the option I wrote works pretty good for me(even though not looking perfect). – JackPot16 Aug 15 '17 at 14:57
  • just use [this](https://pasteboard.co/GFM4D0P.png) as a `Drawable source` and `Drawable mask`, `ColorDrawable(Color.BLACK)` as a `Drawable shadow` and `8` as `float shadowRadius` and see how it looks like – pskink Aug 15 '17 at 15:00
  • It works! But What if my drawable is a NinePatchDrawable? – JackPot16 Aug 16 '17 at 05:37
  • well, for NinePatchDrawable it could not work as it needs `getIntrinsicWidth` / `Height` - but you have the idea how it might be done - the best idea is debug step-by-step and see the `bitmap` in the debugger - it has the nice feature: `View Bitmap` or something similar – pskink Aug 16 '17 at 05:40

0 Answers0