5

カスタム ダイアログの影を作成したいのですが、可能ですか?

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();
}

style.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>

それを行うための解決策はありますか?

4

2 に答える 2

1

これを試して、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>

View を作成し、上記の xml をその背景に設定します。

 <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-->
   />

ビューの左側に影を落としたい場合は、このビューを左のビューに合わせてください。下に影をつけたい場合は、このビューをビューの下に合わせてください。

于 2013-04-03T11:43:43.897 に答える