Android——自定义Dialog
创建dialog实例:
Dialog dialog = new Dialog(Context context,int theme);
一般大家都是想让Dialog显示自己的布局这里的theme写在style文件内具体内容如下:
<stylename="dialog_tran"parent="android:style/Theme.Dialog"><itemname="android:windowFrame">@null</item><itemname="android:windowNoTitle">true</item><itemname="android:windowBackground">@android:color/transparent</item><itemname="android:windowIsFloating">true</item><itemname="android:windowContentOverlay">@null</item><itemname="android:windowIsTranslucent">true</item><itemname="android:backgroundDimEnabled">false</item><itemname="android:backgroundDimAmount">0.4</item></style><stylename="dialog_untran"parent="dialog_tran"><itemname="android:backgroundDimEnabled">true</item></style>
3.setContentView():
(1)setContentView(int layoutId):如果采用这个方法则可以在XML布局文件设置最外层布局的大小,这样dialog显示的大小就是在布局文件中设置的大小;
(2)setContentView(View view):采用这个方法,不管在布局文件中最外层布局文件的宽高为何则均全屏显示,此时我们可以将布局文件次外层布局看做我们想要呈现的布局即可达到效果;
声明:本站所有文章资源内容,如无特殊说明或标注,均为采集网络资源。如若本站内容侵犯了原著者的合法权益,可联系本站删除。