I want to create a shadow for my custom dialog is that possible ?
GhazalActivity.public void viewShareMenu() {
Dialog share=new Dialog(this,R.style.s
I have created my own custom dialog with a dropped shadow, you can use it as your desire, in the first step you should create a Android shape for both shadow and dialog frame. Here is what I have supplied (dialog_frame_shadow.xml):
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<shape android:shape="rectangle"> <!-- this shape is used as shadow -->
<padding android:bottom="5dp"
android:left="5dp"
android:right="5dp"
android:top="5dp"/>
<solid android:color="#44000000"/>
<corners android:radius="5dp"/>
</shape>
</item>
<item>
<shape android:shape="rectangle"> <!-- this is for dialog frame -->
<corners android:radius="5dp"/>
<stroke android:color="#ff272727" android:width="2dp" />
<gradient android:angle="90"
android:startColor="#ffa7a7a7"
android:centerColor="#ff6a6a6a"
android:endColor="#ffa7a7a7"
android:type="linear"/>
</shape>
</item>
</layer-list>
In the next step you should change your dialog theme as what is in the following:
<style name="my_dialog_theme">
...
<item name="android:windowBackground">@drawable/dialog_frame_shadow</item>
...
</style>
Now you are done, just create a new instance of the Dialog
class and apply this theme to it (in Dialog constructor):
Dialog dialog = new Dialog(this, R.style.my_dialog_theme);
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
dialog.setContentView(R.layout.mdialog);
dialog.show();
Here is its screenshot:
try this, create an xml
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle">
<gradient
android:startColor="#ffffff"
android:centerColor="#d3d7cf"
android:endColor="#2e3436"
android:angle="90" />
</shape>
make a View and set above xml to its backgroung like:
<View android:id="@+id/divider" android:background="@drawable/black_white_gradient"
android:layout_width="match_parent" android:layout_height="5sp"
<!--greater the height, more wider the shadow-->
/>
now if you want to drop shadow to the left of your view, align this view to you views left, if you want shadow on bottom, align this view under you view ...hope you get it now