您的位置:首页 > 移动开发 > Android开发

android 设置activity为对话框,且背景为透明

2013-10-22 15:28 651 查看
1.在drawable/目录下建立文件:bg_transparent.xml<?xml version="1.0" encoding="utf-8"?><shape xmlns:android="http://schemas.android.com/apk/res/android" >
    <solid android:color="#88000000" /> <!-- 实体设置为透明 -->
    <stroke        android:width="1dp"        color="#FFFFFF" />
    <corners android:radius="20dp" />
    <padding        android:bottom="1dp"        android:left="1dp"        android:right="1dp"        android:top="1dp" />
</shape>
2.在values/ 目录下,建立风格文件style.xml<?xml version="1.0" encoding="utf-8"?><resources> <!-- Theme  --> <style name="mytheme" parent="android:style/Theme.Dialog">
        <!-- <item name="android:paddingBottom">100px</item> -->        <item name="android:windowBackground">@drawable/upload_dialog</item>        <item name="android:windowIsTranslucent">true</item>        <item                  name="android:windowAnimationStyle">@+android:style/Animation.Translucent</item>    </style></resources>
3.在Manifest.xml中:<activity android:exported="true"        android:label="@string/app_name"        android:name=".ShowChatMessageActivity"         android:theme="@style/mytheme"></activity>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: