位置: 编程技术 - 正文
推荐整理分享利用activity自定义dialog 开发总结(activity的自定义流程),希望有所帮助,仅作参考,欢迎阅读内容。
文章相关热门搜索词:自定义activity,activity怎么写,activity怎么用,activity怎么写,activity自定义表单,activity自定义表单,activity怎么用,activity怎么用,内容如对您有帮助,希望把文章链接给更多的朋友!
第一步:styles.xml 定义prog_dialog:
<style name="prog_dialog" parent="@android:style/Theme.Holo.Light.Dialog.NoActionBar.MinWidth"> <!--继承父theme下的一种dialog样式--> <item name="android:windowBackground">@android:color/transparent</item> <!-- 因为要为dialog设置圆角,这里设为透明,不再有四个小黑角。dialog背景通过activity的xml文件设置 --> <item name="android:backgroundDimEnabled">false</item><!-- 因为要通过dialog设置屏幕亮度,这里设为不模糊 -->
不要在styles.xml设置dialog的background </style>
第二步:manifest.xml 中为activity 设置自定义style样式:
<activity android:name=".MainTabActivity" android:configChanges="orientation|keyboardHidden|screenSize" android:screenOrientation="portrait" android:theme="@style/prog_dialog"> </activity>
第三步:在drawable 中建立dialog的background ,在activity布局文件中引用:
progress_dialog_bg.xml
<?xml version="1.0" encoding="utf-8"?><layer-list xmlns:android=" > <item> <shape> <solid android:color="#f" /> <corners android:topLeftRadius="dp" android:topRightRadius="dp" android:bottomRightRadius="dp" android:bottomLeftRadius="dp" /> <stroke android:width="1dp" android:color="#aaaaaa" /> </shape> </item> </layer-list>
activty布局文件引用backgroud: 多次试验在style.xml 的item中定义dialog的background会给tabhost 的各个组件分别加上背景,会重叠,导致背景色彩差异,特别是圆角混乱
<TabHost android:padding="2dp" android:background="@drawable/progress_dialog_bg" android:id="@android:id/tabhost" android:layout_width="match_parent" android:layout_height="match_parent" > <TabWidget android:id="@android:id/tabs" android:layout_width="match_parent" android:layout_height="dp" android:layout_gravity="top"> </TabWidget> <FrameLayout android:id="@android:id/tabcontent" android:layout_width="match_parent" android:layout_height="match_parent" android:layout_marginTop="dp" > </FrameLayout> </TabHost>
第四步:Java代码定义dialog显示位置
// 设置dialog位置Window dialog = getWindow();dialog.setGravity(Gravity.BOTTOM);// 以下6行代码设置dialog 的宽高WindowManager m = getWindowManager();Display d = m.getDefaultDisplay(); // 为获取屏幕宽、高android.view.WindowManager.LayoutParams p = getWindow().getAttributes(); // p.height = (int) (d.getHeight() * 0.5); // 高度设置为屏幕的0.5p.width = (int) (d.getWidth() * 0.); // 宽度设置为屏幕的0.p.y =;//设置dialog 上下偏移量,这里设为,开发完成要测试不同分辨率手机,再调整getWindow().setAttributes(p);
沉浸式状态栏调用方法 MIUI6上大受好评的沉浸式状态栏其实是谷歌原生自带的一种样式(4.4以上版本支持),我们也可以通过带买来轻松实现@TargetApi()privatevoidsetTranslucentStatus
d:skin 开头的无效内容。此处不应含有子元素。 androidsdkmanager更新了androidsdk:报错的信息如下:[AndroidSDK]ErrorwhenloadingtheSDK:Error:ErrorparsingD:android-sdkssystem-imagesandroid-android-weararmeabi-v7adevices.xmlcvc-com
android调用系统相机、调用系统相册,调用系统图片裁剪报错的解决方案 最近在项目中用到了照相和相册取图剪裁上传头像,就在网上逛了逛,基本都是千篇一律,就弄下来用了用,没想到的是各种各样的奇葩问题就出现了
标签: activity的自定义流程
本文链接地址:https://www.jiuchutong.com/biancheng/385143.html 转载请保留说明!友情链接: 武汉网站建设