当前位置:网站首页>Timed disappearance pop-up
Timed disappearance pop-up
2022-07-05 10:16:00 【asahi_ xin】
preparation
1. Call parameters
<!-- Color -->
<color name="transparent">#00000000</color>
<color name="black">#000000</color>
<color name="white">#FFFFFF</color>
<!-- font size -->
<dimen name="text_size_16sp">16sp</dimen>
<!-- written words -->
<string name="close_after__seconds">%s Seconds to close </string>
<!-- style -->
<style name="sp_dialog" parent="@android:style/Theme.Dialog">
<item name="android:windowFrame">@null</item> <!-- Frame -->
<item name="android:windowIsFloating">true</item> <!-- Whether it appears in activity above -->
<item name="android:windowIsTranslucent">false</item> <!-- translucent -->
<item name="android:windowNoTitle">true</item> <!-- No title -->
<item name="android:windowBackground">@android:color/transparent</item> <!-- The background is transparent -->
<item name="android:backgroundDimEnabled">true</item> <!-- Fuzzy -->
</style>
2. background
dialog_common_bg
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<corners android:radius="20dp" />
<solid android:color="@color/white" />
<stroke
android:width="1dp"
android:color="@color/white" />
</shape>
3. picture
Main code
public class WaitTimeDialog extends Dialog {
public WaitTimeDialog(@NonNull Context context, int themeResId) {
super(context, themeResId);
}
public static void create(Context context, int millisInFuture, int countDownInterval) {
WaitTimeDialog dialog = new WaitTimeDialog(context, R.style.sp_dialog);
dialog.setContentView(R.layout.dialog_wait_time);
dialog.setCancelable(false);
dialog.show();
TextView tip = dialog.findViewById(R.id.tip);
tip.setText(String.format(context.getString(R.string.close_after__seconds), millisInFuture + ""));
CountDownTimer countDownTimer = new CountDownTimer((millisInFuture + countDownInterval) * 1000, countDownInterval * 1000) {
@Override
public void onTick(long millisUntilFinished) {
tip.setText(String.format(context.getString(R.string.close_after__seconds), millisUntilFinished / 1000 + ""));
}
@Override
public void onFinish() {
dialog.dismiss();
}
};
countDownTimer.start();
}
}
dialog_wait_time
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="130dp"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:background="@color/transparent"
android:orientation="vertical">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/dialog_common_bg"
android:orientation="vertical">
<ImageView
android:id="@+id/img"
android:layout_width="40dp"
android:layout_height="40dp"
android:layout_centerHorizontal="true"
android:layout_gravity="center"
android:layout_marginTop="20dp"
android:src="@drawable/icon_confirm" />
<TextView
android:id="@+id/tip"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/img"
android:layout_marginBottom="10dp"
android:layout_marginTop="10dp"
android:gravity="center"
android:textColor="@color/black"
android:textSize="@dimen/text_size_16sp" />
</RelativeLayout>
</LinearLayout>
边栏推荐
- 苹果 5G 芯片研发失败?想要摆脱高通为时过早
- QT realizes signal transmission and reception between two windows
- Livedata interview question bank and answers -- 7 consecutive questions in livedata interview~
- Getting started with Apache dolphin scheduler (one article is enough)
- 官网给的这个依赖是不是应该为flink-sql-connector-mysql-cdc啊,加了依赖调
- IDEA新建sprintboot项目
- Events and bubbles in the applet of "wechat applet - Basics"
- RMS TO EAP通过MQTT简单实现
- 面试:List 如何根据对象的属性去重?
- Is it really reliable for AI to make complex decisions for enterprises? Participate in the live broadcast, Dr. Stanford to share his choice | qubit · viewpoint
猜你喜欢
如何写出高质量的代码?
Advanced opencv:bgr pixel intensity map
ConstraintLayout的流式布局Flow
学习笔记6--卫星定位技术(上)
isEmpty 和 isBlank 的用法区别
[论文阅读] CKAN: Collaborative Knowledge-aware Atentive Network for Recommender Systems
如何獲取GC(垃圾回收器)的STW(暫停)時間?
Node red series (29): use slider and chart nodes to realize double broken line time series diagram
Constraintlayout officially provides rounded imagefilterview
MySQL字符类型学习笔记
随机推荐
uniapp + uniCloud+unipay 实现微信小程序支付功能
A high density 256 channel electrode cap for dry EEG
AtCoder Beginner Contest 258「ABCDEFG」
Unity particle special effects series - the poison spray preform is ready, and the unitypackage package is directly used - on
MySQL digital type learning notes
Kotlin Compose 与原生 嵌套使用
QT realizes signal transmission and reception between two windows
@JsonAdapter注解使用
伪类元素--before和after
天龙八部TLBB系列 - 单体技能群伤
Meitu lost 300 million yuan in currency speculation for half a year. Huawei was exposed to expand its enrollment in Russia. Alphago's peers have made another breakthrough in chess. Today, more big new
Livedata interview question bank and answers -- 7 consecutive questions in livedata interview~
程序员如何活成自己喜欢的模样?
Events and bubbles in the applet of "wechat applet - Basics"
双容水箱液位模糊PID控制系统设计与仿真(Matlab/Simulink)
QT VT100 parser
善用兵者,藏于无形,90 分钟深度讲解最佳推广价值作品
Hard core, have you ever seen robots play "escape from the secret room"? (code attached)
Lepton 无损压缩原理及性能分析
【系统设计】指标监控和告警系统