当前位置:网站首页>Live broadcast software development, customized pop-up effect of tools
Live broadcast software development, customized pop-up effect of tools
2022-07-27 15:59:00 【Cloudleopard network technology】
Live software development , Custom pop-up effect of tool class
1. Pop up box with button ( With an OK button )
private void showDialog(String content){
View view = LayoutInflater.from(mContext).inflate(R.layout.dialog_licence,null,false);
final AlertDialog dialog = new AlertDialog.Builder(mContext).setView(view).create();
TextView btn_agree_high_opion = view.findViewById(R.id.tv_confirm);
TextView tv_content = view.findViewById(R.id.tv_dialog_msg);
tv_content.setText(content);
btn_agree_high_opion.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
//... To-do
dialog.dismiss();
}
});
dialog.show();
int width = mContext.getResources().getDisplayMetrics().widthPixels;
// Set the position form size here , I set it here to the width of the mobile phone screen 3/4 Attention must be paid to show Method and then write the code to set the window size , Otherwise, it will not work
// dialog.getWindow().setLayout((height/4*3), LinearLayout.LayoutParams.WRAP_CONTENT);
Window win = dialog.getWindow();
win.setGravity(Gravity.CENTER); // Here you can control the pop-up position
win.getDecorView().setPadding(0, 0, 0, 0);
WindowManager.LayoutParams lp = win.getAttributes();
lp.width = width/2;
lp.height = WindowManager.LayoutParams.WRAP_CONTENT;
dialog.getWindow().setBackgroundDrawable(null);
win.setAttributes(lp);
}
Layout file example ( The layout file is a little messy , Just an example ):
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_marginLeft="@dimen/px30"
android:layout_marginRight="@dimen/px30"
android:background="@drawable/bg_radius_gray"
android:orientation="vertical" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="@dimen/px100"
android:gravity="center"
android:orientation="vertical" >
<TextView
android:id="@+id/tv_dialog_msg"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_margin="@dimen/px20"
android:gravity="center"
android:textColor="@color/color_333333"
android:textSize="@dimen/font_14" />
</LinearLayout>
<View
android:layout_width="fill_parent"
android:layout_marginHorizontal="@dimen/px20"
android:layout_height="@dimen/px1"
android:background="@color/color_515c74" />
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="bottom"
android:orientation="horizontal" >
<TextView
android:id="@+id/tv_confirm"
android:layout_width="fill_parent"
android:layout_height="@dimen/px68"
android:layout_weight="1"
android:gravity="center"
android:text="@string/common_confirm_text"
android:textColor="@color/color_333333"
android:textSize="@dimen/font_14" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
- Without button , Do not write the pop-up box of the layout file
//3 Seconds disappear automatically
AlertDialog.Builder builder = new AlertDialog.Builder(mContext);
// builder.setTitle(" Send successfully !");
builder.setMessage(content);
builder.setCancelable(true);
final AlertDialog dlg = builder.create();
dlg.show();
final Timer t = new Timer();
t.schedule(new TimerTask() {
public void run() {
dlg.dismiss();
t.cancel();
}
}, 3000);
Window win = dlg.getWindow();
win.setGravity(Gravity.CENTER); // Here you can control the pop-up position
// win.getDecorView().setPadding(0, 0, 0, 0);
int width = mContext.getResources().getDisplayMetrics().widthPixels;
WindowManager.LayoutParams lp = win.getAttributes();
lp.width = width/5*3;
lp.height = WindowManager.LayoutParams.WRAP_CONTENT;
dlg.getWindow().setBackgroundDrawableResource(R.drawable.bg_radius_gray);
win.setAttributes(lp);
That's all Live software development , Custom pop-up effect of tool class , More content welcome to follow the article
边栏推荐
- [sword finger offer] interview question 39: numbers that appear more than half of the time in the array
- 减小程序rom ram,gcc -ffunction-sections -fdata-sections -Wl,–gc-sections 参数详解
- C语言实现字节流与十六进制字符串的相互转换
- Ncnn reasoning framework installation; Onnx to ncnn
- 聊聊ThreadLocal
- Spark 3.0 DPP implementation logic
- Talk about ThreadLocal
- Catalog component design and custom extended catalog implementation in spark3
- Insert sort directly
- Go language slow start -- go operator
猜你喜欢

UDP message structure and precautions

Voice live broadcast system -- a necessary means to improve the security of cloud storage

Push down of spark filter operator on parquet file

Constraints, design and joint query of data table -- 8000 word strategy + Exercise answers

The risk of multithreading -- thread safety

Insert sort directly

Addition, deletion, query and modification of MySQL table data

网络层的IP协议

First acquaintance with MySQL database

初识MySQL数据库
随机推荐
Text batch replacement function
[regular expression] single character matching
Paper_Book
Network device hard core technology insider router Chapter 22
synchronized和ReentrantLock的区别
openwrt 编译驱动模块(在openwrt源代码外部任意位置编写代码,独立模块化编译.ko)
减小程序rom ram,gcc -ffunction-sections -fdata-sections -Wl,–gc-sections 参数详解
Spark troubleshooting finishing
C language: string function and memory function
It is said that the US government will issue sales licenses to Huawei to some US enterprises!
CAS比较交换的知识、ABA问题、锁升级的流程
Sword finger offer 51. reverse pairs in the array
Using Prometheus to monitor spark tasks
[sword finger offer] interview question 52: the first common node of two linked lists - stack, hash table, double pointer
为应对RISC-V挑战?Arm CPU引入自定义指令功能!
C语言:函数栈帧
[sword finger offer] interview question 51: reverse pairs in the array - merge sort
C语言实现字节流与十六进制字符串的相互转换
SQL multi table query
Push down of spark filter operator on parquet file