Inside my app, if the button's background has a corner radius, then you can see the shadow behind it, and I am trying to remove that shadow.
I have tried:
android:stateListAnimator="#null"
style="?android:attr/borderlessButtonStyle"
android:shadowRadius="0"
But none of them works.
As you can see from the picture, the shadow is very light but visible, especially at the bottom left and right corners.
Try to use style .
<style name="MyButtonStyle" parent="#style/Widget.AppCompat.Button.Borderless"></style>
You can use TextView instead of Button. and set background and clickListener for your TextView. and u will never have this shadow .
Maybe you can set a shadow color of transparent.
But I am not sure it will be work.
Hope can help you.
Related
I want to change Floating Action button shadow colour from black/grey to colorprimary/custom color of shadow ** shadow example like below image with **center blue FAB button with light blue shadow not grey shadow. But we can change the FAB button background color. But as you can see in image there is blue shadow of FAB button.I want to achive that thing.
try this :: app:backgroundTint="#color/colorAccentGrey"
where colorAccentGrey = YourColor
and put xmlns:app="http://schemas.android.com/apk/res-auto" at the beginning of the XML if you forggt,
and for Remove shadow :: app:elevation="0dp"
Hope this will help you.. :)
I think you have 2 options:
as #Uttam said, change the elevation of the FAB widget
to make a custom design and embed it as an image in your layout as shown here http://androidgifts.com/android-material-design-floating-action-button-tutorial/
None of the answer worked for me. So i worked this. anyhow it will give shadow like effect that enough for me
<com.google.android.material.floatingactionbutton.FloatingActionButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/ic_add_black"
app:elevation="0dp" // disable outside shawdow
app:borderWidth="30dp" // make borderwidth to 25dp or height of fab
app:backgroundTint="#00E5FF" // now you will see only this color with shawdow
android:backgroundTint="#00E5FF" // since border is 30dp u ll not see this color and if you want to check reduce border width to 25dp then ull see this color in center as a small dot.
/>
A simple solution is to remove the stroke(border-width), the default value is 0.5dp change it to 0dp, that is
app:borderWidth="0dp"
Refer Regular and mini FAB key properties in Material Design documentation!
Link - https://material.io/components/buttons-floating-action-button/android
I have my Card View set up like this:
android:layout_marginTop="2dp"
android:layout_marginLeft="6dp"
android:layout_marginRight="6dp"
card_view:cardCornerRadius="2dp"
card_view:cardElevation="6dp"
card_view:cardUseCompatPadding="true"
card_view:contentPadding="10p"
Without a background color my Card View looks perfect like this:
However, when I add the simple property:
card_view:cardBackgroundColor="#xxxxxxxx"
the shadows change significantly in terms of color, transparency, blur etc.
How might I go about fixing this? I tried using a RelativeLayout as the background and changing the color there, so it wouldn't affect the shadows... but that affected the rounded corners.
Any ideas? Thanks for the help!
I ran into the exact same problem and solved it by removing the alpha portion of my hex code.
Example: #AA333333 removing the AA. Of course use the hex color that you need without the alpha.
Your idea of RelativeLayout is a good one. Instead of placing the card view in RelativeLayout, add RelativeLayout as CardView child, and than add its content to RelativeLayout, in your case it look like you got single child: TextView.
So change your TextView background color or place it in a RelativeLayout and change RelativeLayout background color.
As a workaround, since the alpha is the problem, you can try to brigthen the card color (or blend it with the underlying color)
ColorUtils.blendARGB(yourCardColor, Color.WHITE, 0.2f)
Instead of that, set android:background="#hexColor"
I'm trying to use Fragmentto put ImageButton in my app, but i don't want to see translucent grey background like this:
i want to see only round button. How to do it?
You can also use this
android:background="#android:color/transparent"
Put below property in ImageButton.
android:background="#null"
Is there a way to totally remove the Icon from a RadioButton?
I'm bolding the text instead of using the icon.
Setting android:button to either #null or #android:color/transparent
only hides the button and still messes up my test positioning.
I suppose that I could use a dummy view that's only 1dip big, but I wanted to check if there was less of a hack.
Try setting the background and button to #null.
set android:button="#null" will remove the default radio icon
I have an ImageButton and I'd like to remove the ugly (IMHO) background that surrounds the Image. I could just add an ImageView, but they're very hard to get set perfectly in a Layout like the grey one pictured. [gravity "Center" doesn't make it go to the middle, just centers it Vertically.)
So any way to remove that?
Just use android:background="#0000"
(#0000 same with #00000000)
or
ImageButton imageButton = new ImageButton(this);
imageButton.setBackgroundDrawable(null);
The default background is not transparent.
So, just add the transparent color "#00000000" as you background, then you could solve it.
p.s. #00000000 is the transparent color
<ImageButton
android:id="#+id/imageButton1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/icon"
android:background="#00000000"
/>
You can keep the square box and just change its color like this:
android:backgroundTint="#color/colorPrimary"
works beautifully
I'm having the same problem but now it has been solved. If you are using "android:background="#null" it will resulted of no background at all and no button pressed animation will be appeared to the user.
Just adding this line of code to make an image button become flashing upon clicked. This is the proper way to alert the user an image button has been clicked.
"android:background="?android:selectableItemBackground"
just useandroid:background="#null" in your xml
if you set the
android:background
instead of
android:src
it should overwrite the gray background
Yeah. If you drag ImageButton that will usually ask for ImageSource. But the ImageSource(android:src) doesn't remove the gray background. It is an image that should be on top of background:
Instead of that try android:background in layout XML.
please use the Draw 9-patch format for the image b'use it is provided by SDK
1. From a terminal, launch the draw9patch application from your SDK /tools directory.
2. Drag your PNG image into the Draw 9-patch window (or File > Open 9-patch... to locate the file). Your workspace will now open.
The left pane is your drawing area, in which you can edit the lines for the stretchable patches and content area. The right pane is the preview area, where you can preview your graphic when stretched.
3. Click within the 1-pixel perimeter to draw the lines that define the stretchable patches and (optional) content area. Right-click (or hold Shift and click, on Mac) to erase previously drawn lines.
4. When done, select File > Save 9-patch...
Your image will be saved with the .9.png file name.
Use like this
android:background="#android:color/transparent"
android:src="#drawable/icon"
All proposed solutions remove the ripple animation (on tap)
Settings background tint mode to 'add' will remove the background and keep ripple animation:
android:backgroundTintMode="add"
If using Xamarin Forms it can be done like this in the xaml view. Set background to transparent.
<ImageButton BackgroundColor="Transparent"