欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

Android實(shí)現(xiàn)從底部彈出的Dialog的實(shí)例代碼

 更新時(shí)間:2018年04月09日 11:42:33   作者:拽是男人的本性  
這篇文章主要介紹了Android實(shí)現(xiàn)從底部彈出的Dialog的實(shí)例代碼,非常不錯(cuò),具有參考借鑒價(jià)值 ,需要的朋友可以參考下

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

2.彈框

Dialog dialog = new Dialog(context, R.style.ActionSheetDialogStyle);
    //填充對話框的布局
    inflate = LayoutInflater.from(context).inflate(R.layout.dialog_layout, null);
    // setCancelable(iscancelable);//點(diǎn)擊外部不可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)容會(huì)自適應(yīng),而不會(huì)充滿父控件
    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)入及退出動(dòng)畫 -->
  <item name="android:windowAnimationStyle">@style/ActionSheetDialogAnimation</item>
 </style>
 <!-- ActionSheet進(jìn)出動(dòng)畫 -->
 <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)動(dòng)畫代碼:

<?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.效果圖

總結(jié)

以上所述是小編給大家介紹的Android實(shí)現(xiàn)從底部彈出的Dialog的實(shí)例代碼,希望對大家有所幫助,如果大家有任何疑問請給我留言,小編會(huì)及時(shí)回復(fù)大家的。在此也非常感謝大家對腳本之家網(wǎng)站的支持!

相關(guān)文章

  • android仿微信聯(lián)系人索引列表功能

    android仿微信聯(lián)系人索引列表功能

    這篇文章主要為大家詳細(xì)介紹了android仿微信聯(lián)系人索引列表功能,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2017-11-11
  • Android獲取驗(yàn)證碼倒計(jì)時(shí)顯示效果

    Android獲取驗(yàn)證碼倒計(jì)時(shí)顯示效果

    這篇文章主要為大家詳細(xì)介紹了Android獲取驗(yàn)證碼顯示的兩種簡單實(shí)現(xiàn),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2016-10-10
  • Android?Studio實(shí)現(xiàn)智能聊天

    Android?Studio實(shí)現(xiàn)智能聊天

    這篇文章主要為大家詳細(xì)介紹了Android?Studio實(shí)現(xiàn)智能聊天,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2022-07-07
  • Android使用自定義控件HorizontalScrollView打造史上最簡單的側(cè)滑菜單

    Android使用自定義控件HorizontalScrollView打造史上最簡單的側(cè)滑菜單

    側(cè)滑菜單一般都會(huì)自定義ViewGroup,然后隱藏菜單欄,當(dāng)手指滑動(dòng)時(shí),通過Scroller或者不斷的改變leftMargin等實(shí)現(xiàn);多少都有點(diǎn)復(fù)雜,完成以后還需要對滑動(dòng)沖突等進(jìn)行處理,今天給大家?guī)硪粋€(gè)簡單的實(shí)現(xiàn),史上最簡單有點(diǎn)夸張,但是的確是我目前遇到過的最簡單的一種實(shí)現(xiàn)
    2016-02-02
  • Android ADT 離線下載操作步驟

    Android ADT 離線下載操作步驟

    這篇文章主要介紹了Android ADT 離線下載操作步驟的相關(guān)資料,需要的朋友可以參考下
    2017-04-04
  • Android studio導(dǎo)入項(xiàng)目的方法詳解(簡單快速)

    Android studio導(dǎo)入項(xiàng)目的方法詳解(簡單快速)

    最近開課移動(dòng)互聯(lián)網(wǎng)應(yīng)用開發(fā),實(shí)驗(yàn)課老師發(fā)了代碼讓我們導(dǎo)入,在網(wǎng)上找了各種方法,發(fā)現(xiàn)不是每一個(gè)項(xiàng)目都適合,有些能夠成功,有些還是有錯(cuò),頭大的很。后面發(fā)現(xiàn)一個(gè)比較簡單的方法,沒翻過車,新手可以試試
    2017-06-06
  • Android中Blade的使用方法

    Android中Blade的使用方法

    這篇文章主要介紹了Android中Blade的使用實(shí)例詳解,需要的朋友可以參考下
    2018-02-02
  • Android實(shí)現(xiàn)照片墻效果的實(shí)例代碼

    Android實(shí)現(xiàn)照片墻效果的實(shí)例代碼

    Android實(shí)現(xiàn)照片墻效果的設(shè)計(jì)思路其實(shí)也非常簡單,用一個(gè)GridView控件當(dāng)作“墻”,然后隨著GridView的滾動(dòng)將一張張照片貼在“墻”上,這些照片可以是手機(jī)本地中存儲(chǔ)的,也可以是從網(wǎng)上下載的
    2018-05-05
  • Android系統(tǒng)默認(rèn)對話框添加圖片功能

    Android系統(tǒng)默認(rèn)對話框添加圖片功能

    這篇文章主要介紹了Android系統(tǒng)默認(rèn)對話框添加圖片的相關(guān)資料,非常不錯(cuò),具有參考借鑒價(jià)值,需要的朋友可以參考下
    2017-01-01
  • Android convinientbanner頂部廣告輪播控件使用詳解

    Android convinientbanner頂部廣告輪播控件使用詳解

    這篇文章主要為大家詳細(xì)介紹了Android convinientbanner頂部廣告輪播控件,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2017-01-01

最新評論