Android版本更新彈出對話框的實現(xiàn)方式

啥都不說瓦侮,先上圖准给,

然后貼一下具體代碼见间,代碼如下:

首先是布局文件dialog_layout:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"

? ? android:layout_width="match_parent"

? ? android:layout_height="wrap_content"

? ? android:layout_centerInParent="true"

? ? android:background="@android:color/transparent">

? ? ? ? android:layout_width="match_parent"

? ? ? ? android:layout_height="wrap_content"

? ? ? ? android:layout_alignParentRight="true"

? ? ? ? android:layout_centerInParent="true"

? ? ? ? android:layout_centerVertical="true"

? ? ? ? android:layout_marginTop="@dimen/dimens_20"

? ? ? ? android:layout_marginRight="@dimen/dimens_10"

? ? ? ? android:layout_marginLeft="@dimen/dimens_10"

? ? ? ? android:background="@drawable/bg_border_dialog"

? ? ? ? android:minWidth="260dp"

? ? ? ? android:orientation="vertical">

? ? ? ? ? ? android:layout_width="150dp"

? ? ? ? ? ? android:layout_height="150dp"

? ? ? ? ? ? android:layout_gravity="center"

? ? ? ? ? ? android:layout_marginTop="@dimen/dimens_10"

? ? ? ? ? ? android:src="@mipmap/update_icon" />

? ? ? ? ? ? android:layout_width="match_parent"

? ? ? ? ? ? android:layout_height="wrap_content"

? ? ? ? ? ? android:layout_marginTop="@dimen/dimens_10"

? ? ? ? ? ? android:gravity="center"

? ? ? ? ? ? android:text="發(fā)現(xiàn)有新版本"

? ? ? ? ? ? android:textColor="@color/text_content"

? ? ? ? ? ? android:textSize="@dimen/textSize_16"

? ? ? ? ? ? android:textStyle="bold" />

? ? ? ? ? ? android:layout_width="match_parent"

? ? ? ? ? ? android:layout_height="wrap_content"

? ? ? ? ? ? android:layout_marginLeft="@dimen/dimens_20"

? ? ? ? ? ? android:layout_marginTop="@dimen/dimens_10"

? ? ? ? ? ? android:layout_marginRight="@dimen/dimens_20"

? ? ? ? ? ? android:layout_marginBottom="@dimen/dimens_10"

? ? ? ? ? ? android:gravity="center"

? ? ? ? ? ? android:text="第二個版本,修復了若干bug. "

? ? ? ? ? ? android:textSize="@dimen/textSize_14"

? ? ? ? ? ? android:textStyle="bold" />

? ? ? ? ? ? android:id="@+id/uptate_tv_version"

? ? ? ? ? ? android:layout_width="match_parent"

? ? ? ? ? ? android:layout_height="@dimen/dimens_40"

? ? ? ? ? ? android:layout_marginLeft="@dimen/dimens_20"

? ? ? ? ? ? android:layout_marginRight="@dimen/dimens_20"

? ? ? ? ? ? android:layout_marginBottom="@dimen/dimens_20"

? ? ? ? ? ? android:background="@drawable/ripple_press13"

? ? ? ? ? ? android:gravity="center"

? ? ? ? ? ? android:text="立即更新"

? ? ? ? ? ? android:textColor="@color/white" />

? ? ? ? android:id="@+id/dialogseven_delete"

? ? ? ? android:layout_width="30dp"

? ? ? ? android:layout_height="30dp"

? ? ? ? android:layout_alignParentRight="true"

? ? ? ? android:background="@mipmap/update_delete"

? ? ? ? android:visibility="visible"/>

</RelativeLayout>

------------------------------------------------------------------------------

其次是顯示dialog方法:------------------------------------

private void initUpdateDialog() {

picChooseDialog =new Dialog(AboutUsActivity.this, R.style.CustomDialog);

? ? View view = LayoutInflater.from(AboutUsActivity.this).inflate(

R.layout.test, null);

? ? final TextView uptate_tv_version = view.findViewById(R.id.uptate_tv_version);

? ? uptate_tv_version.setOnClickListener(new View.OnClickListener() {

@Override

? ? ? ? public void onClick(View v) {

}

});

? ? Window window =picChooseDialog.getWindow();

? ? window.setContentView(view);

? ? window.setGravity(Gravity.CENTER);

? ? window.setLayout(WindowManager.LayoutParams.WRAP_CONTENT,

? ? ? ? ? ? android.view.WindowManager.LayoutParams.WRAP_CONTENT);

? ? window.setWindowAnimations(R.style.popupWindowAnimation);

? ? picChooseDialog.setCanceledOnTouchOutside(true);

? ? picChooseDialog.show();

}

style樣式也貼出來吧:---------------------------------------

<style name="CustomDialog" parent="android:style/Theme.Dialog">


? ? <item name="android:windowBackground">@android:color/transparent


? ? <item name="android:windowNoTitle">true


? ? <item name="android:windowFrame">@null


? ? <item name="android:windowIsFloating">true


? ? <item name="android:backgroundDimEnabled">true


好了悉默,這是所有的更新版本的對話框哮缺。

最后編輯于
?著作權歸作者所有,轉載或內容合作請聯(lián)系作者
  • 序言:七十年代末,一起剝皮案震驚了整個濱河市,隨后出現(xiàn)的幾起案子虏两,更是在濱河造成了極大的恐慌愧旦,老刑警劉巖,帶你破解...
    沈念sama閱讀 222,252評論 6 516
  • 序言:濱河連續(xù)發(fā)生了三起死亡事件碘举,死亡現(xiàn)場離奇詭異忘瓦,居然都是意外死亡,警方通過查閱死者的電腦和手機引颈,發(fā)現(xiàn)死者居然都...
    沈念sama閱讀 94,886評論 3 399
  • 文/潘曉璐 我一進店門耕皮,熙熙樓的掌柜王于貴愁眉苦臉地迎上來,“玉大人蝙场,你說我怎么就攤上這事凌停。” “怎么了售滤?”我有些...
    開封第一講書人閱讀 168,814評論 0 361
  • 文/不壞的土叔 我叫張陵罚拟,是天一觀的道長。 經常有香客問我完箩,道長赐俗,這世上最難降的妖魔是什么? 我笑而不...
    開封第一講書人閱讀 59,869評論 1 299
  • 正文 為了忘掉前任弊知,我火速辦了婚禮阻逮,結果婚禮上,老公的妹妹穿的比我還像新娘秩彤。我一直安慰自己叔扼,他們只是感情好,可當我...
    茶點故事閱讀 68,888評論 6 398
  • 文/花漫 我一把揭開白布漫雷。 她就那樣靜靜地躺著瓜富,像睡著了一般。 火紅的嫁衣襯著肌膚如雪降盹。 梳的紋絲不亂的頭發(fā)上与柑,一...
    開封第一講書人閱讀 52,475評論 1 312
  • 那天,我揣著相機與錄音蓄坏,去河邊找鬼仅胞。 笑死,一個胖子當著我的面吹牛剑辫,可吹牛的內容都是我干的。 我是一名探鬼主播渠欺,決...
    沈念sama閱讀 41,010評論 3 422
  • 文/蒼蘭香墨 我猛地睜開眼妹蔽,長吁一口氣:“原來是場噩夢啊……” “哼!你這毒婦竟也來了?” 一聲冷哼從身側響起胳岂,我...
    開封第一講書人閱讀 39,924評論 0 277
  • 序言:老撾萬榮一對情侶失蹤编整,失蹤者是張志新(化名)和其女友劉穎,沒想到半個月后乳丰,有當?shù)厝嗽跇淞掷锇l(fā)現(xiàn)了一具尸體掌测,經...
    沈念sama閱讀 46,469評論 1 319
  • 正文 獨居荒郊野嶺守林人離奇死亡,尸身上長有42處帶血的膿包…… 初始之章·張勛 以下內容為張勛視角 年9月15日...
    茶點故事閱讀 38,552評論 3 342
  • 正文 我和宋清朗相戀三年产园,在試婚紗的時候發(fā)現(xiàn)自己被綠了汞斧。 大學時的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片。...
    茶點故事閱讀 40,680評論 1 353
  • 序言:一個原本活蹦亂跳的男人離奇死亡什燕,死狀恐怖粘勒,靈堂內的尸體忽然破棺而出,到底是詐尸還是另有隱情屎即,我是刑警寧澤庙睡,帶...
    沈念sama閱讀 36,362評論 5 351
  • 正文 年R本政府宣布,位于F島的核電站技俐,受9級特大地震影響乘陪,放射性物質發(fā)生泄漏。R本人自食惡果不足惜雕擂,卻給世界環(huán)境...
    茶點故事閱讀 42,037評論 3 335
  • 文/蒙蒙 一啡邑、第九天 我趴在偏房一處隱蔽的房頂上張望。 院中可真熱鬧捂刺,春花似錦谣拣、人聲如沸。這莊子的主人今日做“春日...
    開封第一講書人閱讀 32,519評論 0 25
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽。三九已至仪缸,卻和暖如春贵涵,著一層夾襖步出監(jiān)牢的瞬間,已是汗流浹背恰画。 一陣腳步聲響...
    開封第一講書人閱讀 33,621評論 1 274
  • 我被黑心中介騙來泰國打工宾茂, 沒想到剛下飛機就差點兒被人妖公主榨干…… 1. 我叫王不留,地道東北人拴还。 一個月前我還...
    沈念sama閱讀 49,099評論 3 378
  • 正文 我出身青樓跨晴,卻偏偏與公主長得像,于是被迫代替她去往敵國和親片林。 傳聞我的和親對象是個殘疾皇子端盆,可洞房花燭夜當晚...
    茶點故事閱讀 45,691評論 2 361