How to make a long oval shape with custom shadow in Android - android

I think i mentioned the name of the shape wrong.
I want to make shape like the following image with shadows in Android,
Sample model
So how to make this type of layout in Android .
thanx for the help!!

You should try this one:
https://github.com/Hitomis/CrazyShadow
By drawable you can generate the shape, and by using this library you will be able to add shadow.
Or:
You can use the library itself.

Related

Shadow color android studio

I have a ui design.
I should to make some xml file with custom shadow color.
I used to carbon library but it not work very well
I need to create shadow like this
enter image description here
This should work for Android version 28 or higher.
In your xml layout, include this in your CardView.
android:outlineAmbientShadowColor="<yourColor>"
android:outlineSpotShadowColor="<yourColor>"
You can do the same in code by doing this:
mCardView.setOutlineAmbientShadowColor(ContextCompat.getColor(getContext(), R.color.color_blue));
mCardView.setOutlineSpotShadowColor(ContextCompat.getColor(getContext(), R.color.colour_blue));

shadow effect in android color cardview

Want this kind of shadow effect with android card view except for white background with cardview property, neither use with the canvas draw mechanism nor 9 patch image mechanism
want to use only drawable shape or cardview properties. TIA
EDIT: There is this github project you can use to get custom shadow for CardView. Just implement it in your project and use this instead of androidx components. Link: https://github.com/nvl2val/CardView/tree/master
2nd EDIT: Also another workaround for this issue. Read this thread: Android change Material elevation shadow color
I don't really get your question but CardView itself has a lot of properties you can play with. Check this documentation for more: https://developer.android.com/reference/androidx/cardview/widget/CardView
Using elevation will give you shadow by default so if you don't want a shadow on objects with a white background you need to set the elevation to 0. Here you can play with
android:elevation = "10dp"
app:cardElevation = "10dp"
and see which one does the job better for you. Also, try adding some padding to your parent layout so that CardView has some space around. All this and maybe more you can find in this answer: https://stackoverflow.com/a/46374054/14759470

How to give any shape to Views?

How to give any shape to Views in android
I want following background to textview.
You can create shapes using xml drawables in Android.
https://developer.android.com/guide/topics/resources/drawable-resource.html#Shape
But the background you want is not straightforward using xml. So I recommend creating background using any image editor and set it as background of the textview.
Another approach would be to create vector drawable for the required shape which is supported from android API 21. Here is a good tutorial to create your your own shapes and images
https://medium.com/#ali.muzaffar/understanding-vectordrawable-pathdata-commands-in-android-d56a6054610e
To customize a View you should create a custom view. Create a new class by extending the View class, implement all public constructors and override the onDraw function. When using in the layout file give the full path of the custom view:
<com.example.ownview.MyDrawView
android:id="#+id/myDrawView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />

Create a custom shape

How to create a custom shape like below image?
Any help would be appreciated.
Make a new class that extends view.
In the onDraw() use moveTo and lineTo to make the exact shape you want.
In your layout, use:
<com.example.yourpackage.YourViewClass android:id...
you should override onDraw() method to create a custom shapes
this page may help you
http://developer.android.com/training/custom-views/custom-drawing.html
You can use this library PathDrawable
PathDrawable is a Drawable that draws simple shapes using Path object.
try this site its generate XML code for Shape
http://angrytools.com/android/button/

How to make styles for Rounted Rectangle button in android

I need xml styles for tab on or off state,whenever i click the button,display rounded rectangle on button.How can i make new style for given image.please give some tips for me
how to create styles for rounded rectangle like this image
For that add rounded cornered images as a background to tab:
tab = tabs.newTabSpec("tab_Busquedas");
tab.setContent(new Intent().setClassName("com.grapp", "com.grapp.homes").putExtras(bundle));
tab.setIndicator(null,null);
tabs.addTab(tab);
//here you set the image with rounded corners over the tab.
tabs.getTabWidget().getChildAt(0).setBackgroundResource(R.drawable.mytab_roundedcorners);
This solution is posted at: How to achieve rounded tabs in Android 2.1 +
You can make use of the themes feature for the same.
http://developer.android.com/guide/topics/ui/themes.html
If you make use of this feature, maintainability will also be easy.
Regards,
SSuman185

Categories

Resources