当前位置:网站首页>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>
边栏推荐
- Design of stepping motor controller based on single chip microcomputer (forward rotation and reverse rotation indicator gear)
- flink cdc不能监听mysql日志,大家遇到过这个问题吧?
- 苹果 5G 芯片研发失败?想要摆脱高通为时过早
- ArcGIS Pro creating features
- 历史上的今天:第一本电子书问世;磁条卡的发明者出生;掌上电脑先驱诞生...
- How do programmers live as they like?
- 【小技巧】获取matlab中cdfplot函数的x轴,y轴的数值
- QT event filter simple case
- 面试:List 如何根据对象的属性去重?
- [tips] get the x-axis and y-axis values of cdfplot function in MATLAB
猜你喜欢
历史上的今天:第一本电子书问世;磁条卡的发明者出生;掌上电脑先驱诞生...
Implementation of smart home project
Kotlin Compose 与原生 嵌套使用
Unity粒子特效系列-毒液喷射预制体做好了,unitypackage包直接用 - 上
Usage differences between isempty and isblank
What is the origin of the domain knowledge network that drives the new idea of manufacturing industry upgrading?
【系统设计】指标监控和告警系统
《微信小程序-基础篇》小程序中的事件与冒泡
《天天数学》连载58:二月二十七日
MySQL character type learning notes
随机推荐
面试:List 如何根据对象的属性去重?
历史上的今天:第一本电子书问世;磁条卡的发明者出生;掌上电脑先驱诞生...
@SerializedName注解使用
QT VT100 parser
如何獲取GC(垃圾回收器)的STW(暫停)時間?
Detailed explanation of the use of staticlayout
天龙八部TLBB系列 - 关于包裹掉落的物品
橫向滾動的RecycleView一屏顯示五個半,低於五個平均分布
MySQL数字类型学习笔记
mongoDB副本集
isEmpty 和 isBlank 的用法区别
MySQL character type learning notes
ConstraintLayout官方提供圆角ImageFilterView
Applet image height adaptation and setting text line height
一种用于干式脑电图的高密度256通道电极帽
把欧拉的创新带向世界 SUSE 要做那个引路人
Livedata interview question bank and answers -- 7 consecutive questions in livedata interview~
IDEA新建sprintboot项目
[论文阅读] CKAN: Collaborative Knowledge-aware Atentive Network for Recommender Systems
QT realizes signal transmission and reception between two windows