当前位置:网站首页>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>
边栏推荐
- How do programmers live as they like?
- Design of stepping motor controller based on single chip microcomputer (forward rotation and reverse rotation indicator gear)
- 历史上的今天:第一本电子书问世;磁条卡的发明者出生;掌上电脑先驱诞生...
- 最全是一次I2C总结
- The king of pirated Dall · e? 50000 images per day, crowded hugging face server, and openai ordered to change its name
- [论文阅读] CKAN: Collaborative Knowledge-aware Atentive Network for Recommender Systems
- Kotlin Compose 与原生 嵌套使用
- Single chip microcomputer principle and Interface Technology (esp8266/esp32) machine human draft
- Dedecms website building tutorial
- @JsonAdapter注解使用
猜你喜欢
Getting started with Apache dolphin scheduler (one article is enough)
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
Unity particle special effects series - the poison spray preform is ready, and the unitypackage package is directly used - on
Kotlin compose and native nesting
@SerializedName注解使用
《微信小程序-基础篇》小程序中的事件与冒泡
Six simple cases of QT
Cent7 Oracle database installation error
Kotlin Compose 多个条目滚动
[C language] the use of dynamic memory development "malloc"
随机推荐
MySQL digital type learning notes
天龙八部TLBB系列 - 关于包裹掉落的物品
Redis如何实现多可用区?
Implementation of smart home project
QT timer realizes dynamic display of pictures
Tianlong Babu TLBB series - questions about skill cooling and the number of attack ranges
leetcode:1200. 最小绝对差
如何写出高质量的代码?
最全是一次I2C总结
isEmpty 和 isBlank 的用法区别
面试:Bitmap像素内存分配在堆内存还是在native中
程序员搞开源,读什么书最合适?
一个程序员的职业生涯到底该怎么规划?
WorkManager的学习二
[NTIRE 2022]Residual Local Feature Network for Efficient Super-Resolution
@JsonAdapter注解使用
Wechat applet - simple diet recommendation (3)
Livedata interview question bank and answers -- 7 consecutive questions in livedata interview~
> Could not create task ‘:app:MyTest.main()‘. > SourceSet with name ‘main‘ not found.问题修复
oracle和mysql批量Merge对比