Android Question Use centered image for panel background

ArminKH

Well-Known Member
hi
as u know image view has a property named gravity which has two special gravity named Gravity.Fill and Center
now i have a panel and i want to use an image as a background for this panel which is a drawable or bitmap
but images in panel's background have the Fill gravity as default and will be stretched but i want to use some thing like Gravity.Center property for a panel similar to image view
i know panel has not gravity and maybe we need to set drawable or bitmaps gravity and i know it's possible by add another panel or image view into base panel but what i'm looking for it is a direct way to achieve to this
thanks in advance
 
Last edited:

Erel

B4X founder
Staff member
Licensed User
Longtime User
You can use BitmapDrawable and change its gravity property.

SS-2016-03-24_17.19.14.png
 
Upvote 0

ArminKH

Well-Known Member
thank u @Erel
B4X:
Private Sub setBitmapDrawableGravity(Drawable As BitmapDrawable, DrawableGravity As Int)
        Dim jo As JavaObject = Drawable
        jo.RunMethod("setGravity",Array(DrawableGravity))
End Sub
 
Upvote 0
Top