android 自定义对话框 背景透明
2011-09-02 16:44
465 查看
1、定义style:
<resources>
<style
name="dialog_fullscreen">
<item
name="android:windowFullscreen">true</item>
<item
name="android:windowNoTitle">true</item>
<item
name="android:windowBackground">@android:color/transparent</item>
</style>
</resources>
2、定义layout文件:test_dialog.xml
<LinearLayout
android:id="@+id/ll_dialog"
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_gravity="center"
android:background="#000000">
……
</LinearLayout>
3、代码中设置:
public class TestDialog extends Dialog
{
public TestDialog(Context context)
{
super(context, R.style.dialog_fullscreen);
// TODO Auto-generated constructor stub
}
@Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.test_dialog);
// 设置背景透明度
View ll = findViewById(R.id.ll_dialog);
ll.getBackground().setAlpha(120);// 120为透明的比率
}
}
本文来自CSDN博客,转载请标明出处:http://blog.csdn.net/cruel/archive/2011/01/05/6118806.aspx
<resources>
<style
name="dialog_fullscreen">
<item
name="android:windowFullscreen">true</item>
<item
name="android:windowNoTitle">true</item>
<item
name="android:windowBackground">@android:color/transparent</item>
</style>
</resources>
2、定义layout文件:test_dialog.xml
<LinearLayout
android:id="@+id/ll_dialog"
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_gravity="center"
android:background="#000000">
……
</LinearLayout>
3、代码中设置:
public class TestDialog extends Dialog
{
public TestDialog(Context context)
{
super(context, R.style.dialog_fullscreen);
// TODO Auto-generated constructor stub
}
@Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.test_dialog);
// 设置背景透明度
View ll = findViewById(R.id.ll_dialog);
ll.getBackground().setAlpha(120);// 120为透明的比率
}
}
本文来自CSDN博客,转载请标明出处:http://blog.csdn.net/cruel/archive/2011/01/05/6118806.aspx
相关文章推荐
- android 自定义对话框 背景透明
- Android开发:自定义对话框(自定义布局及背景透明等)
- Android自定义对话框,背景颜色透明
- Android自定义全透明Dalog对话框以及自定义全透明Taost弹出框+对话框背景模糊处理
- Android编程实现对话框Dialog背景透明功能示例
- android 自定义Dialog背景透明及显示位置设置
- android 对话框Dialog背景透明
- android 自定义dialog并实现失去焦点(背景透明)的功能
- Android中利用Activity自定义背景透明、大小和位置Dialog
- android 自定义Dialog背景透明及显示位置设置
- Android 创建自定义对话框主题(使用半透明背景也不会露出原有的背景了)
- 浅谈自定义不规则背景的对话框,透明背景的对话框dialog定义过程中的注意事项
- android 自定义Dialog背景透明及显示位置设置
- android 自定义Dialog背景透明及显示位置设置
- Android自定义半透明背景弹窗非popwindow/dialog超简单任意编写!
- android 自定义Dialog背景透明及显示位置设置
- android自定义透明对话框,透明提示框,自定义Dialog
- android 自定义Dialog背景透明及显示位置设置
- Android对话框的自定义及透明效果
- android 自定义Dialog背景透明及显示位置设置