I am trying to implement the alignment feature ContentVertical Alignment found in ios for the android image button. It would be easier to use setGravity() however, image button does not support this method. Is there a way to work around this somehow?
Try scaleType attribute.
Related
I want add shadow to layouts like below image :
http://s9.picofile.com/file/8321463292/android.png
I do not want use android:elevation, because not working for android 4.3
Also, I use these libraries but not work correct for me :
https://github.com/loopeer/shadow
https://github.com/dmytrodanylyk/shadow-layout
https://github.com/Devlight/ShadowLayout
https://github.com/harjot-oberai/MaterialShadows
https://github.com/xuehuayous/Android-ShadowView
How i can set shadow to layouts like top image ? ( smooth, 100% radius and colorful)
Thank you
I have two suggestions to make shadow as per your requirement
you can use 9-patch image, may be this link will help you to create 9-patch with shadow
alternate
solution is to make gradient and set background to your button view.
How can I use scaleType for an image in a button?
I am using a button with drawableTop (image with text below it). I have an image and I want it to fit the button boundries (currently it is too big to fit and resulting in truncated image)
There is no scaleType attribute for button so how can I do it?
Thank you
What you need is android nine-patch images to be used as button background.
There is a good tutorial here
Also look here Here
I want to add an image(the user image) in the centre of the button and also maintain the background colour(grey) of the button.
I tried to use the background attribute along with the padding but it seems to have no effect.
Can anyone please guide me how to do it ?
Should I be using the attributes drawableTop etc in my xml ???
Please help.
Do not set the image as the background. Instead, use an ImageButton and specify your image as the source (src attribute).
That way you can specify things such as scale type, padding, etc. Keep in mind that using padding sometimes doesn't work properly on Android version 2.2.
i'm trying to add these kind of IOS shadows in the back of a imageview on Android:
I mean the rear shadow in the back of each square. Imagine that each square is an Android IMAGEVIEW, how can i add this shadow in Android?
Try this below link to your shadow problem
Custom ImageView with drop shadow
Welcome
If I have a custom image can I write over it, will it always write to the center of the button image? Ie will setText on image always right to center of the image provided or do I need to do something to have this effect? Thanks Also is it better to use ImageButton or set Image as background of Button? and write over it that way. I want to use 3d images and write on top of them in black text.
I don't know if there is a preformance difference for using image button of a normal button, but I'd imagine that and image button will work better. Albiet I always just use a normal button and setBackground(...). Also if you want to set the text to always be in the middle, use android:gravity="center" in the layout file.