Android半透明对话框实现
2011-01-05 21:01
375 查看
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为透明的比率
}
}
<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为透明的比率
}
}
相关文章推荐
- 利用半透明对话框实现新浪微博android客户端首次运行时的提示界面
- 利用半透明对话框实现新浪微博android客户端首次运行时的提示界面
- 利用半透明对话框实现新浪微博android客户端首次运行时的提示界面
- 利用半透明对话框实现新浪微博android客户端首次运行时的提示界面
- 利用半透明对话框实现新浪微博android客户端首次运行时的提示界面
- 利用半透明对话框实现新浪微博android客户端首次运行时的提示界面
- 利用半透明对话框实现新浪微博android客户端首次运行时的提示界面
- 利用半透明对话框实现android运行时的提示界面
- 利用半透明对话框实现新浪微博android客户端首次运行时的提示界面
- 利用半透明对话框实现新浪微博android客户端首次运行时的提示界面
- Android 选择文件对话框并将选择内容添加至ListView,并实现listview的删除与事件触发
- Android开发必知--几种不同对话框的实现
- Android开发必知--几种不同对话框的实现
- Android:实现点击AlertDialog上按钮时不关闭对话框
- Android 里的对话框Dialog 实现机制基础
- android中使用PopupWindow实现取消确定对话框
- Android的同步对话框(AlertDialog模态对话框返回值实现原理)
- Android实现半透明的popupwindow
- Android Dialog点击对话框外部让其消失的实现方法
- android基础(对话框风格Activity实现)