Android實(shí)現(xiàn)圓角彈框功能
自定義彈窗類——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);//點(diǎn)擊其他區(qū)域時(shí) true 關(guān)閉彈窗 false 不關(guān)閉彈窗 tvmydailog01 = findViewById(R.id.tv_mydailog01); tvmydailog02 = findViewById(R.id.tv_mydailog02); ivdailog = findViewById(R.id.iv_mydailog); } /*設(shè)置圖片接口*/ public void setImageResource(int resId){ ivdailog.setImageResource(resId); } /*設(shè)置文字接口*/ public void setText01(String str){ tvmydailog01.setText(str); } public void setText02(String str){ tvmydailog02.setText(str); } /*設(shè)置文字顏色接口*/ 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);//加載布局 //設(shè)置透明背景 Window window = getWindow(); window.setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT)); } }
xml布局文件
<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/dialog_view" 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:id="@+id/iv_mydailog" android:layout_width="wrap_content" android:layout_height="66dp" android:src="@drawable/icon_warning" /> <TextView android:id="@+id/tv_mydailog01" 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:id="@+id/tv_mydailog02" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/str_push_true_phone" android:textColor="#ff555555" android:textSize="15sp" /> </LinearLayout>
調(diào)用
MySetDailog mySetDailog = new MySetDailog(BindActivity.this); mySetDailog.show();
到此這篇關(guān)于Android實(shí)現(xiàn)圓角彈框功能的文章就介紹到這了,更多相關(guān)android圓角彈框內(nèi)容請(qǐng)搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!
相關(guān)文章
Android實(shí)現(xiàn)模仿UCweb菜單效果的方法
這篇文章主要介紹了Android實(shí)現(xiàn)模仿UCweb菜單效果的方法,較為詳細(xì)的分析了Android模仿UCweb菜單效果的頁(yè)面布局及功能實(shí)現(xiàn)技巧,具有一定參考借鑒價(jià)值,需要的朋友可以參考下2015-10-10Android仿微信錄音功能(錄音后的raw文件轉(zhuǎn)mp3文件)
這篇文章主要介紹了Android中仿微信錄音功能錄音后的raw文件轉(zhuǎn)mp3文件,本文通過實(shí)例代碼給大家講解的非常詳細(xì),需要的朋友可以參考下2019-11-11android獲取情景模式和鈴聲 實(shí)現(xiàn)震動(dòng)、鈴聲提醒
這篇文章主要介紹了android獲取情景模式和鈴聲,實(shí)現(xiàn)震動(dòng)、鈴聲提醒,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2016-12-12Android編程實(shí)現(xiàn)播放視頻時(shí)切換全屏并隱藏狀態(tài)欄的方法
這篇文章主要介紹了Android編程實(shí)現(xiàn)播放視頻時(shí)切換全屏并隱藏狀態(tài)欄的方法,結(jié)合實(shí)例形式分析了Android視頻播放事件響應(yīng)及相關(guān)屬性設(shè)置操作技巧,需要的朋友可以參考下2017-08-08詳解Android數(shù)據(jù)存儲(chǔ)—使用SQLite數(shù)據(jù)庫(kù)
本篇文章主要介紹了詳解Android數(shù)據(jù)存儲(chǔ)—使用SQLite數(shù)據(jù)庫(kù),具有一定的參考價(jià)值,有興趣的可以了解一下。2017-03-03Android自定義Seekbar滑動(dòng)條 Pop提示跟隨滑動(dòng)按鈕滑動(dòng)
這篇文章主要為大家詳細(xì)介紹了Android自定義Seekbar滑動(dòng)條,Pop提示跟隨滑動(dòng)按鈕滑動(dòng),文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2018-07-07Android中ScrollView實(shí)現(xiàn)滑動(dòng)距離監(jiān)聽器的方法
ScrollView相信對(duì)每位Android開發(fā)者們來說都不陌生,所以這篇文章給大家主要介紹了Android中ScrollView實(shí)現(xiàn)滑動(dòng)距離監(jiān)聽器的方法,有需要的朋友們可以參考借鑒,下面來一起看看吧。2016-10-10Android AIDL實(shí)現(xiàn)兩個(gè)APP間的跨進(jìn)程通信實(shí)例
這篇文章主要為大家詳細(xì)介紹了Android AIDL實(shí)現(xiàn)兩個(gè)APP間的跨進(jìn)程通信實(shí)例,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2018-04-04