中文字幕第五页-中文字幕第页-中文字幕韩国-中文字幕最新-国产尤物二区三区在线观看-国产尤物福利视频一区二区

Android實現(xiàn)從底部彈出的Dialog的方法

這篇文章將為大家詳細(xì)講解有關(guān)Android實現(xiàn)從底部彈出的Dialog的方法,小編覺得挺實用的,因此分享給大家做個參考,希望大家閱讀完這篇文章后可以有所收獲。

創(chuàng)新互聯(lián)主營札達(dá)網(wǎng)站建設(shè)的網(wǎng)絡(luò)公司,主營網(wǎng)站建設(shè)方案,app軟件定制開發(fā),札達(dá)h5微信小程序搭建,札達(dá)網(wǎng)站營銷推廣歡迎札達(dá)等地區(qū)企業(yè)咨詢

1.點擊按鈕(按鈕的點擊事件在此不在贅述,接下來直接寫底部彈框的實現(xiàn)方式和樣式的設(shè)計)

2.彈框

Dialog dialog = new Dialog(context, R.style.ActionSheetDialogStyle);
    //填充對話框的布局
    inflate = LayoutInflater.from(context).inflate(R.layout.dialog_layout, null);
    // setCancelable(iscancelable);//點擊外部不可dismiss
    //setCanceledOnTouchOutside(isBackCanCelable);
    //初始化控件
    spinner = (Spinner) inflate.findViewById(R.id.sp);
    beizhu = (TextView) inflate.findViewById(R.id.beizhu);
    btn_cancel = (Button) inflate.findViewById(R.id.btn_cancel);
    btn_ok = (Button) inflate.findViewById(R.id.btn_ok);
    //將布局設(shè)置給Dialog
    taskProgress.setContentView(inflate);
    //獲取當(dāng)前Activity所在的窗體
    Window dialogWindow = taskProgress.getWindow();
    //設(shè)置Dialog從窗體底部彈出
    dialogWindow.setGravity(Gravity.BOTTOM);
    //獲得窗體的屬性
    WindowManager.LayoutParams lp = dialogWindow.getAttributes();
    //如果沒有這行代碼,彈框的內(nèi)容會自適應(yīng),而不會充滿父控件
    lp.width = WindowManager.LayoutParams.MATCH_PARENT;
    lp.y = 40;//設(shè)置Dialog距離底部的距離
    //將屬性設(shè)置給窗體
    dialogWindow.setAttributes(lp);
    dialog .show();//顯示對話框
    在需要消失地方直接
    dialog.dismiss();

3.窗口的樣式

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

  <!-- 背景透明 -->
  <item name="android:windowBackground">@android:color/transparent</item>
  <item name="android:windowContentOverlay">@null</item>
  <!-- 浮于Activity之上 -->
  <item name="android:windowIsFloating">true</item>
  <!-- 邊框 -->
  <item name="android:windowFrame">@null</item>
  <!-- Dialog以外的區(qū)域模糊效果 -->
  <item name="android:backgroundDimEnabled">true</item>
  <!-- 無標(biāo)題 -->
  <item name="android:windowNoTitle">true</item>
  <!-- 半透明 -->
  <item name="android:windowIsTranslucent">true</item>
  <!-- Dialog進(jìn)入及退出動畫 -->
  <item name="android:windowAnimationStyle">@style/ActionSheetDialogAnimation</item>
 </style>
 <!-- ActionSheet進(jìn)出動畫 -->
 <style name="ActionSheetDialogAnimation" parent="@android:style/Animation.Dialog">
  <item name="android:windowEnterAnimation">@anim/actionsheet_dialog_in</item>
  <item name="android:windowExitAnimation">@anim/actionsheet_dialog_out</item>
 </style>

4.窗口出現(xiàn)和消失的效果

對話框出現(xiàn)動畫代碼:

<?xml version="1.0" encoding="utf-8"?>
<translate xmlns:android="http://schemas.android.com/apk/res/android"
 android:duration="200"
 android:fromYDelta="100%"
 android:toYDelta="0" />

對話框消失的代碼:

<?xml version="1.0" encoding="utf-8"?>
<translate xmlns:android="http://schemas.android.com/apk/res/android"
 android:duration="200"
 android:fromYDelta="0"
 android:toYDelta="100%" />

5.彈框的整體布局

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
 xmlns:tools="http://schemas.android.com/tools"
 android:id="@+id/activity_task_progress"
 android:layout_width="match_parent"
 android:layout_height="match_parent"
 android:gravity="center"
 android:orientation="vertical">
 <LinearLayout
  android:layout_width="match_parent"
  android:layout_height="wrap_content"
  android:layout_margin="20dp"
  android:background="@drawable/lin_style"
  android:gravity="center_vertical"
  android:orientation="vertical">
  <LinearLayout
   android:layout_width="match_parent"
   android:layout_height="wrap_content"
   android:layout_margin="20dp"
   android:layout_marginLeft="10dp"
   android:layout_marginRight="10dp"
   android:orientation="horizontal">
   <TextView
    android:layout_width="0dp"
    android:layout_height="match_parent"
    android:layout_weight="1"
    android:gravity="center"
    android:text="任務(wù)進(jìn)度"
    android:textSize="17sp" />
   <Spinner
    android:id="@+id/sp"
    android:layout_width="0dp"
    android:layout_height="wrap_content"
    android:layout_weight="2"></Spinner>
  </LinearLayout>
  <LinearLayout
   android:layout_width="match_parent"
   android:layout_height="wrap_content"
   android:layout_marginBottom="10dp"
   android:layout_marginTop="20dp"
   android:focusable="true"
   android:focusableInTouchMode="true"
   android:orientation="horizontal">
   <TextView
    android:layout_width="0dp"
    android:layout_height="match_parent"
    android:layout_weight="1"
    android:gravity="center"
    android:text="備注"
    android:textSize="17sp" />
   <EditText
    android:id="@+id/beizhu"
    android:layout_width="0dp"
    android:layout_height="wrap_content"
    android:layout_weight="2"
    android:hint="請輸入備注" />
  </LinearLayout>
 </LinearLayout>
 <LinearLayout
  android:layout_width="match_parent"
  android:layout_height="wrap_content"
  android:layout_marginBottom="10dp"
  android:layout_marginTop="5dp"
  android:orientation="horizontal">
  <Button
   android:id="@+id/btn_cancel"
   android:layout_width="0dp"
   android:layout_height="wrap_content"
   android:layout_gravity="center_vertical"
   android:layout_marginLeft="50dp"
   android:layout_marginRight="50dp"
   android:layout_weight="1"
   android:background="@drawable/button_style"
   android:minHeight="0dp"
   android:minWidth="0dp"
   android:paddingBottom="8dp"
   android:paddingLeft="10dp"
   android:paddingRight="10dp"
   android:paddingTop="8dp"
   android:text="取消"
   android:textColor="#fff" />
  <Button
   android:id="@+id/btn_ok"
   android:layout_width="0dp"
   android:layout_height="wrap_content"
   android:layout_gravity="center_vertical"
   android:layout_marginLeft="50dp"
   android:layout_marginRight="50dp"
   android:layout_weight="1"
   android:background="@drawable/button_style"
   android:minHeight="0dp"
   android:minWidth="0dp"
   android:paddingBottom="8dp"
   android:paddingLeft="10dp"
   android:paddingRight="10dp"
   android:paddingTop="8dp"
   android:text="確定"
   android:textColor="#fff" />
 </LinearLayout>
</LinearLayout>

6.lin_style樣式

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
 <corners android:radius="10dp"></corners>
 <solid android:color="#fff" />
</shape>

7.button_style樣式

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
 <corners android:radius="5dp"></corners>
 <solid android:color="#46b5e9" />
</shape>

6.效果圖

Android實現(xiàn)從底部彈出的Dialog的方法

關(guān)于“Android實現(xiàn)從底部彈出的Dialog的方法”這篇文章就分享到這里了,希望以上內(nèi)容可以對大家有一定的幫助,使各位可以學(xué)到更多知識,如果覺得文章不錯,請把它分享出去讓更多的人看到。

分享題目:Android實現(xiàn)從底部彈出的Dialog的方法
文章網(wǎng)址:http://www.2m8n56k.cn/article38/ggdgpp.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供企業(yè)網(wǎng)站制作網(wǎng)站排名軟件開發(fā)網(wǎng)站收錄響應(yīng)式網(wǎng)站域名注冊

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:[email protected]。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)

綿陽服務(wù)器托管
主站蜘蛛池模板: 亚洲码一区二区三区 | 九九久久免费视频 | 精品一区视频 | 久久久久亚洲香蕉网 | 在线欧美精品二区三区 | 一区二区三区欧美在线 | 亚洲精品第五页中文字幕 | 欧美顶级毛片在线播放小说 | 九九草在线观看 | 欧美亚洲一区二区三区四 | 国产亚洲综合精品一区二区三区 | 美国三级在线观看 | 亚洲视频中文字幕 | www.av日韩| 亚洲精品视频区 | 四色永久 | 国产福利社区 | 国产成人久久久精品毛片 | 欧美高清一级毛片免费视 | 成人一级网站 | 成人9久久国产精品品 | 亚洲高清在线看 | 亚洲精品成人 | 手机看片在线播放 | 欧美刺激午夜性久久久久久久 | 久久不见久久见免费影院 | 亚洲精品一区二区三区四 | 成年人看的毛片 | 在线欧美| 日本在线视频播放 | 91精品国产免费久久久久久青草 | 欧美在线小视频 | 国产一区二区在线免费观看 | 精品久久久中文字幕一区 | 日本久久久久一级毛片 | 一区二区三区在线视频观看 | 久草高清在线 | 国产成人免费片在线视频观看 | 欧美成人黄色 | 久久精品片 | 天干夜天天夜天干天ww |