I want to create a shadow for my custom dialog is that possible ?
GhazalActivity.public void viewShareMenu() {
Dialog share=new Dialog(this,R.style.shareDialogStyle);
share.setContentView(R.layout.share_popup_layout);
LayoutParams params = share.getWindow().getAttributes();
params.y = this.getResources().getDimensionPixelSize(R.dimen.topbar_height);
params.gravity=(Gravity.RIGHT|Gravity.TOP);
share.getWindow().setAttributes(params);
share.show();
}
styles.xml :
<style name="shareDialogStyle" parent="android:style/Theme.Dialog">
<item name="android:windowBackground">@color/transparent</item>
<item name="android:windowNoTitle">true</item>
<item name="android:fadeEnabled">true</item>
<item name="android:fadeDuration">1500</item>
<item name="android:shadowColor">@color/temp</item>
<item name="android:shadowDx">0</item>
<item name="android:shadowDy">5</item>
<item name="android:shadowRadius">10</item>
<item name="android:backgroundDimEnabled">false</item>
</style>
share_popup_layout.xml :
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="150dip"
android:background="@color/bg_Ghazal_share_menu"
android:layout_height="wrap_content"
android:orientation="vertical" >
<Button
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="right"
style="@style/shareDialogButtons"/>
</LinearLayout>
is there any solution for doing that ?
try this, create an xml
make a View and set above xml to its backgroung like:
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
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):
In the next step you should change your dialog theme as what is in the following:
Now you are done, just create a new instance of the
Dialog
class and apply this theme to it (in Dialog constructor):Here is its screenshot: