加载时的动画效果

来源:互联网 发布:数据库系统由什么构成 编辑:程序博客网 时间:2024/04/30 15:22

新建布局myprogresslayout.xml

<ProgressBar
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center"
        android:layout_marginTop="10dip"
        android:background="@drawable/loadingpage_bg"
        android:indeterminateDrawable="@drawable/animdraw"
        android:indeterminateDuration="1500" />

Drawable目录下存放两张图片和xml----位置在桌面加载图片目录下
loadingpage_bg.png,
loadingpage_light.png

animdraw.xml




style下放入代码

</style>    <!--进度条样式-->    <style name="MyDialog" parent="AppTheme">        <!-- 充满屏幕 -->        <item name="android:windowFullscreen">true</item>        <item name="android:windowFrame">@null</item>        <item name="android:windowIsFloating">true</item>        <!-- 是否浮现在activity之上 -->        <item name="android:windowNoTitle">true</item>        <!-- 无标题 -->        <item name="android:windowBackground">@android:color/transparent</item>        <!-- 背景透明 -->        <item name="android:windowIsTranslucent">false</item>        <!-- 半透明 -->        <item name="android:windowContentOverlay">@null</item>        <!-- 内容覆盖 -->        <item name="android:windowAnimationStyle">@android:style/Animation.Dialog</item>        <!-- 窗口样式Dialog -->        <item name="android:backgroundDimEnabled">false</item>        <!--activity不变暗false-->        <!-- 模糊 -->    </style>

Main中代码

//自定义alertdialg---打开public void alertdiag() {    dialog = new Dialog(getActivity(), R.style.MyDialog);    dialog.setContentView(R.layout.myprogresslayout);    dialog.setCanceledOnTouchOutside(false);    dialog.show();}//关闭 public void closeProgressDialog() {    if (dialog != null) {        dialog.dismiss();    }}

0 0
原创粉丝点击