当前位置:网站首页>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
边栏推荐
- 折半插入排序
- 直接插入排序
- leetcode234题-简单方法判断回文链表
- 一款功能强大的Web漏洞扫描和验证工具(Vulmap)
- Leetcode-1: sum of two numbers
- 文字批量替换功能
- [sword finger offer] interview question 41: median in data flow - large and small heap implementation
- Hj8 consolidated statement record
- Mlx90640 infrared thermal imager temperature sensor module development notes (VII)
- openwrt 增加RTC(MCP7940 I2C总线)驱动详解
猜你喜欢

CAS compares the knowledge exchanged, ABA problems, and the process of lock upgrading
![[sword finger offer] interview question 46: translating numbers into strings - dynamic programming](/img/ba/7a4136fd95ba2463556bc45231e8a2.png)
[sword finger offer] interview question 46: translating numbers into strings - dynamic programming

C语言:数据的存储

C语言:扫雷小游戏
![[sword finger offer] interview question 50: the first character that appears only once - hash table lookup](/img/72/b35bdf9bde72423410e365e5b6c20e.png)
[sword finger offer] interview question 50: the first character that appears only once - hash table lookup

Spark Bucket Table Join

Ncnn reasoning framework installation; Onnx to ncnn

C语言:函数栈帧

C语言:自定义类型

C language: dynamic memory function
随机推荐
C language: data storage
[regular expression] match the beginning and end
Spark troubleshooting finishing
[sword finger offer] interview question 53- Ⅱ: missing numbers in 0 ~ n-1 - binary search
可载100人!马斯克发布史上最强“星际飞船” !最早明年上火星!
profileapi.h header
网络设备硬核技术内幕 路由器篇 小结(下)
UDP message structure and precautions
On juicefs
网络设备硬核技术内幕 路由器篇 22
Openwrt增加对 sd card 支持
[Yunxiang book club issue 13] coding format of video files
兆骑科创创业大赛策划承办机构,双创平台,项目落地对接
/Dev/loop1 takes up 100% of the problem
It is said that the US government will issue sales licenses to Huawei to some US enterprises!
折半查找
js操作dom节点
Binder初始化过程
Addition, deletion, query and modification of MySQL table data
Implement custom spark optimization rules