当前位置:网站首页>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>
边栏推荐
- 能源势动:电力行业的碳中和该如何实现?
- Swift set pickerview to white on black background
- MySQL character type learning notes
- To bring Euler's innovation to the world, SUSE should be the guide
- 请问postgresql cdc 怎么设置单独的增量模式呀,debezium.snapshot.mo
- La vue latérale du cycle affiche cinq demi - écrans en dessous de cinq distributions moyennes
- @Jsonadapter annotation usage
- > Could not create task ‘:app:MyTest.main()‘. > SourceSet with name ‘main‘ not found.问题修复
- Design and Simulation of fuzzy PID control system for liquid level of double tank (matlab/simulink)
- Dedecms website building tutorial
猜你喜欢
Cerebral Cortex:有向脑连接识别帕金森病中广泛存在的功能网络异常
What is the origin of the domain knowledge network that drives the new idea of manufacturing industry upgrading?
把欧拉的创新带向世界 SUSE 要做那个引路人
Node red series (29): use slider and chart nodes to realize double broken line time series diagram
【小技巧】获取matlab中cdfplot函数的x轴,y轴的数值
Design of stepping motor controller based on single chip microcomputer (forward rotation and reverse rotation indicator gear)
ArcGIS Pro creating features
Swift set pickerview to white on black background
学习笔记4--高精度地图关键技术(下)
> Could not create task ‘:app:MyTest. main()‘. > SourceSet with name ‘main‘ not found. Problem repair
随机推荐
Theme. AppCompat. Light. Darkactionbar not found
Unity粒子特效系列-毒液喷射预制体做好了,unitypackage包直接用 - 上
QT timer realizes dynamic display of pictures
AtCoder Beginner Contest 258「ABCDEFG」
能源势动:电力行业的碳中和该如何实现?
Interview: how does the list duplicate according to the attributes of the object?
Tianlong Babu TLBB series - about items dropped from packages
Detailed explanation of the use of staticlayout
历史上的今天:第一本电子书问世;磁条卡的发明者出生;掌上电脑先驱诞生...
横向滚动的RecycleView一屏显示五个半,低于五个平均分布
Lepton 无损压缩原理及性能分析
Kotlin Compose 多个条目滚动
QT VT100 parser
[200 opencv routines] 219 Add digital watermark (blind watermark)
The most complete is an I2C summary
Livedata interview question bank and answers -- 7 consecutive questions in livedata interview~
leetcode:1200. 最小绝对差
ArcGIS Pro creating features
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
Apache dolphin scheduler system architecture design