自定义LoadingDialog
2016-12-23 15:29
169 查看
public class LoadingDialog extends Dialog { public LoadingDialog(Context context) { super(context); setLoadingDialog(context); } public LoadingDialog(Context context, int theme) { super(context, theme); setLoadingDialog(context); } private void setLoadingDialog(Context context){ //不可取消 // this.setCancelable(false); LinearLayout linearLayout = new LinearLayout(context); linearLayout.setOrientation(LinearLayout.VERTICAL); linearLayout.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)); ProgressBar progressBar = new ProgressBar(context, null,android.R.attr.progressBarStyle); TextView textView = new TextView(context); LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT); params.setMargins(0, 45, 0, 0); textView.setLayoutParams(params); textView.setTextColor(context.getResources().getColor(R.color.white)); textView.setTextSize(16); textView.setText("正在加载..."); linearLayout.addView(progressBar); linearLayout.addView(textView); this.addContentView(linearLayout, new ViewGroup.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT)); }}
//style文件
<style name="LoadingDialog" parent="android:Theme.Dialog">
<item name="android:windowNoTitle">true</item>
<item name="android:background">#00000000</item>
<item name="android:windowBackground">@android:color/transparent</item>
<item name="android:colorBackgroundCacheHint">@null</item>
<item name="android:windowIsTranslucent">true</item>
</style>//
LoadingDialog dialog = new LoadingDialog(getActivity(), R.style.LoadingDialog);
dialog.show();
//dialog.cancel();
相关文章推荐
- 51nod 1080 两个数的平方和
- [生存志] 第84节 列子淡泊号冲虚
- EntiryFramework中事务操作实例
- ffmpeg加入libass
- Sass的基础知识
- Linux备忘
- java 中 equals() 相等的两个对象,hashcode() 一定相等
- 计算机史前时代名人堂0-总概
- C语言 · 最小公倍数
- eclipse使用--解决maven项目报错:找不到META-INF\MANIFEST.MF文件的问题
- 细说JavaScript单线程的一些事
- Jsp简介
- mysql中文显示乱码,mysql中文显示成问号
- SIGPIPE信号详解
- Log4j简单实用例子 Log4j xml配置方法
- numpy.random 方法
- over partition by与group by
- 4338: BJOI2015 糖果
- 身份证、组织机构代码及营业执照号校验函数
- Linux下ip地址查询