久久r热视频,国产午夜精品一区二区三区视频,亚洲精品自拍偷拍,欧美日韩精品二区

您的位置:首頁技術文章
文章詳情頁

Android實現圓角彈框功能

瀏覽:49日期:2022-09-21 17:40:06

自定義彈窗類——Android 透明圓角彈窗

import android.content.Context;import android.graphics.Color;import android.graphics.drawable.ColorDrawable;import android.os.Bundle;import android.view.Window;import android.widget.ImageView;import android.widget.TextView;import androidx.annotation.NonNull;import androidx.appcompat.app.AlertDialog;public class MySetDailog extends AlertDialog { TextView tvmydailog01; TextView tvmydailog02; ImageView ivdailog; public MySetDailog(@NonNull Context context ) { super(context); setCanceledOnTouchOutside(true);//點擊其他區域時 true 關閉彈窗 false 不關閉彈窗 tvmydailog01 = findViewById(R.id.tv_mydailog01); tvmydailog02 = findViewById(R.id.tv_mydailog02); ivdailog = findViewById(R.id.iv_mydailog); } /*設置圖片接口*/ public void setImageResource(int resId){ ivdailog.setImageResource(resId); } /*設置文字接口*/ public void setText01(String str){ tvmydailog01.setText(str); } public void setText02(String str){ tvmydailog02.setText(str); } /*設置文字顏色接口*/ public void setColor01(int color01){ tvmydailog01.setTextColor(color01); } public void setColor02(int color02){ tvmydailog02.setTextColor(color02); } @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.dialog_mydailog);//加載布局 //設置透明背景 Window window = getWindow(); window.setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT)); }}

Android實現圓角彈框功能

xml布局文件

<?xml version='1.0' encoding='utf-8'?><LinearLayout xmlns:android='http://schemas.android.com/apk/res/android' android: android:layout_width='325dp' android:layout_height='162dp' android:paddingTop='15dp' android:orientation='vertical' android:layout_gravity='center_horizontal' android:gravity='center' android:background='@drawable/bg_round_dailog'> <ImageView android: android:layout_width='wrap_content' android:layout_height='66dp' android:src='http://m.baoyu77737.com/bcjs/@drawable/icon_warning' /> <TextView android: android:layout_width='wrap_content' android:layout_height='wrap_content' android:layout_marginTop='@dimen/dp_12' android:maxLines='1' android:text='@string/str_upload_fail' android:textColor='#BB340F' android:textStyle='bold' android:textSize='18sp' /> <TextView android: android:layout_width='wrap_content' android:layout_height='wrap_content' android:text='@string/str_push_true_phone' android:textColor='#ff555555' android:textSize='15sp' /></LinearLayout>

調用

MySetDailog mySetDailog = new MySetDailog(BindActivity.this);mySetDailog.show();

到此這篇關于Android實現圓角彈框功能的文章就介紹到這了,更多相關android圓角彈框內容請搜索好吧啦網以前的文章或繼續瀏覽下面的相關文章希望大家以后多多支持好吧啦網!

標簽: Android
相關文章:
主站蜘蛛池模板: 桂阳县| 克拉玛依市| 山丹县| 益阳市| 临沭县| 南和县| 陵川县| 扶沟县| 墨江| 乌恰县| 蛟河市| 新昌县| 洛阳市| 大英县| 禹州市| 克拉玛依市| 若尔盖县| 红安县| 天峨县| 麻栗坡县| 清远市| 林口县| 明水县| 梅州市| 上蔡县| 桐庐县| 延津县| 保亭| 遂昌县| 汾西县| 安国市| 连州市| 南康市| 平塘县| 务川| 通辽市| 河东区| 大足县| 三河市| 台湾省| 司法|