i am trying to coding the below image for android app design, i can not get shadow as same as image how i can do it perfectly? and can control with opacity, degree and color of shadow?
You can use cardView which has an elevation attribute which gives shadows to your card view.
also there are third party libraries which you can use like this:
https://github.com/loopeer/shadow
also here is Google documentation which describes how you should use shadows in your ui:
https://developer.android.com/training/material/shadows-clipping
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.
I am trying to implement shadows for my views. I have given a sample image which describe what I want, I need a google standard methods for implementing shadows, I have tried with drawable images but as you know which is not standard method.
You mean like this?
Defining Shadows and Clipping Views
https://developer.android.com/training/material/shadows-clipping.html
You have to use CardView as view container (which is in an official support library) and set properties:
app:cardElevation="4dp" // shadow
app:cardUseCompatPadding="true">
where app namespace is:xmlns:app="http://schemas.android.com/apk/res-auto"
I'm guessing that you're thinking about older devices.
You can render shadows using RenderScript blurs and layer composition. This method is available since Android Froyo. It's pretty easy to create such shadows from scratch. You have to:
Draw a View as a black shape to an offscreen bitmap.
Blur that bitmap with ScriptIntrisincBlur
Draw that bitmap with alpha
Draw the original View on top of that shadow.
You have to specify a blur radius based on View's elevation. You may also offset the shadow a bit. For implementation details see:
https://github.com/ZieIony/Carbon/blob/master/carbon/src/main/java/carbon/shadow/ShadowGenerator.java
And
https://github.com/ZieIony/Carbon/blob/master/carbon/src/main/java/carbon/widget/LinearLayout.java#L128
In general, with API21 you can use the view.setElevation() method.
Better if you use the ViewCompat.setElevation() method.
Pay attention, it creates a shadow only in devices with API21+.
If you would like to create an elevation for other views for device with api<21, you have to use a custom drawable.
Currently the only standard view that supports elevation in all devices, is the CardView.
In this case you can use the setCardElevation() method.
I'm using the CardView layout from the v7 support library as a primary design pattern in my app. It works great on Lollipop as you'd expect and looks like this:
If I run this same app on 4.4 or below the content in the card doesn't go to the edge as seen here:
Is there a way that I can get the content to go to the edges on all versions of Android and not just 5.0?
Thanks
Unfortunately the creators of the CardView didn't come up with an efficient way to create rounded corners that would work for any layout on devices running earlier versions that Lollipop. Because of that, padding is simply added to the content of the cards. To prevent this padding use this method:
cardView.setPreventCornerOverlap(false);
If you do this however, the ImageView's corners will be drawn over the rounded corners of the CardView. A solution to this problem is to create a custom ImageView (or Drawable, or Picasso transfromation...) that draws rounded corners. Check this Gist on how to do that.
Since you are using a common layout for cards with a header image, you could check this library by the same author which creates the rounded corners without padding.
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
I am trying to draw and animate several ImageView items on a screen and I would like to have the images display the blue borders used in other Honeycomb apps (examples of borders here: http://www.youtube.com/watch?v=UPSBctbYc9Q # 1:10).
I've seen hacks/workarounds for older versions of Android using a background image, but I was hoping to avoid that. Can anyone help me to add such borders?
Thanks
I'd suggest just creating a custom view using FrameLayout as its base to layer up the background/border, and then the ImageView on top using an appropriate padding value such that the border remains visible.