欧美一级特黄大片做受成人-亚洲成人一区二区电影-激情熟女一区二区三区-日韩专区欧美专区国产专区

iOS實(shí)現(xiàn)底部彈出PopupWindow效果iOS改變背景透明效果

底部彈出PopupWindow,背景變?yōu)榘胪该餍Ч捎脙煞N方式實(shí)現(xiàn)

創(chuàng)新互聯(lián)專(zhuān)注為客戶(hù)提供全方位的互聯(lián)網(wǎng)綜合服務(wù),包含不限于網(wǎng)站建設(shè)、成都網(wǎng)站設(shè)計(jì)、獨(dú)山子網(wǎng)絡(luò)推廣、微信平臺(tái)小程序開(kāi)發(fā)、獨(dú)山子網(wǎng)絡(luò)營(yíng)銷(xiāo)、獨(dú)山子企業(yè)策劃、獨(dú)山子品牌公關(guān)、搜索引擎seo、人物專(zhuān)訪(fǎng)、企業(yè)宣傳片、企業(yè)代運(yùn)營(yíng)等,從售前售中售后,我們都將竭誠(chéng)為您服務(wù),您的肯定,是我們最大的嘉獎(jiǎng);創(chuàng)新互聯(lián)為所有大學(xué)生創(chuàng)業(yè)者提供獨(dú)山子建站搭建服務(wù),24小時(shí)服務(wù)熱線(xiàn):18982081108,官方網(wǎng)址:aaarwkj.com

先來(lái)看看運(yùn)行效果圖

iOS實(shí)現(xiàn)底部彈出PopupWindow效果 iOS改變背景透明效果
iOS實(shí)現(xiàn)底部彈出PopupWindow效果 iOS改變背景透明效果

[方式一]實(shí)現(xiàn)從底部彈出PopupWindow

原理:定義一個(gè)高度為wrap_content的PopupWindow布局文件,根據(jù)屏幕底部的位置顯示在Bottom

1.首先定義一個(gè)高度為wrap_content的PopupWindow布局文件

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
  android:layout_width="match_parent"
  android:layout_height="wrap_content"
  android:gravity="center"
  android:padding="8dp"
  android:orientation="vertical" >

  <LinearLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:gravity="center"
    android:orientation="vertical"
    android:background="@drawable/shape_info_bg">
    <TextView android:layout_width="match_parent"
      android:layout_height="wrap_content"
      android:padding="8dp"
      android:gravity="center"
      android:textColor="@color/theme_blue"
      android:text="拍照"/>
    <View android:layout_width="match_parent" 
      android:layout_height="0.2dp"
      android:background="@color/theme_blue"/>
    <TextView android:layout_width="match_parent"
      android:layout_height="wrap_content"
      android:padding="8dp"
      android:gravity="center"
      android:textColor="@color/theme_blue"
      android:text="相冊(cè)"/>
  </LinearLayout>

  <RelativeLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_marginTop="5dp"
    android:padding="1dp">
    <Button
      android:id="@+id/btn_cancle"
      android:layout_width="match_parent"
      android:layout_height="wrap_content"
      android:gravity="center"
      android:padding="8dp"
      android:textColor="@color/theme_blue"
      android:background="@drawable/shape_info_bg"
      android:text="取消" />
  </RelativeLayout>
</LinearLayout>

2.在PopupWindow所在的Activity根布局中聲明id(在彈出PopupWindow作為位置參考的相對(duì)View)

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
  android:id="@+id/root_main"
  android:layout_width="match_parent"
  android:layout_height="match_parent"
  android:orientation="vertical" 
  android:background="@color/white">

  <Button android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:text="底部彈出PopupWindow"
    android:onClick="openPop"/>

   <Button android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:text="半透明底部PopupWindow"
    android:onClick="openPop2"/>
</LinearLayout>

3.MainActivity中點(diǎn)擊按鈕彈出PopupWindow

/** 彈出底部對(duì)話(huà)框 */
public void openPop(View view) {
  View popView = LayoutInflater.from(mContext).inflate(
      R.layout.pop_bottom, null);
  View rootView = findViewById(R.id.root_main); // 當(dāng)前頁(yè)面的根佈局
  final PopupWindow popupWindow = new PopupWindow(popView,    LayoutParams.MATCH_PARENT,LayoutParams.WRAP_CONTENT);

  setBackgroundAlpha(0.5f);//設(shè)置屏幕透明度

  popupWindow.setBackgroundDrawable(new BitmapDrawable());
  popupWindow.setFocusable(true);// 點(diǎn)擊空白處時(shí),隱藏掉pop窗口
  // 顯示在根佈局的底部
  popupWindow.showAtLocation(rootView, Gravity.BOTTOM | Gravity.LEFT, 0,
      0);

}

4.設(shè)置背景變?yōu)榘胪该餍Ч?,由于PopupWindow中并未設(shè)置背景色,所以彈出時(shí)PopupWindow以外的部分顯示當(dāng)前Acitivity的內(nèi)容,設(shè)置背景色原理通過(guò)設(shè)置當(dāng)前Activity所在屏幕的透明度來(lái)達(dá)到背景透明的效果!在退出時(shí)popupWindow時(shí),需要恢復(fù)屏幕原有透明度

popupWindow.setOnDismissListener(new OnDismissListener() {
      @Override
      public void onDismiss() {
        // popupWindow隱藏時(shí)恢復(fù)屏幕正常透明度
        setBackgroundAlpha(1.0f);
      }
    });
/**
 * 設(shè)置添加屏幕的背景透明度
 * 
 * @param bgAlpha
 *      屏幕透明度0.0-1.0 1表示完全不透明
 */
public void setBackgroundAlpha(float bgAlpha) {
  WindowManager.LayoutParams lp = ((Activity) mContext).getWindow()
      .getAttributes();
  lp.alpha = bgAlpha;
  ((Activity) mContext).getWindow().setAttributes(lp);
}

[方式二]全屏PopupWindow實(shí)現(xiàn)底部彈出,背景半透明

原理:彈出一個(gè)全屏popupWindow,高度為match_parent,將根布局的Gravity屬性設(shè)置bottom,根布局背景設(shè)置為一個(gè)半透明的顏色#36000000, 彈出時(shí)全屏的popupWindow半透明效果背景覆蓋了在Activity之上 給人感覺(jué)上是popupWindow彈出后,背景變成半透明

布局文件

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
  android:layout_width="match_parent"
  android:layout_height="match_parent"
  android:padding="8dp"
  android:orientation="vertical" 
  android:background="#36000000"
  android:gravity="bottom">

  <LinearLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:gravity="center"
    android:orientation="vertical"
    android:background="@drawable/shape_info_bg">
    <TextView android:layout_width="match_parent"
      android:layout_height="wrap_content"
      android:padding="8dp"
      android:gravity="center"
      android:textColor="@color/theme_blue"
      android:text="拍照"/>
    <View android:layout_width="match_parent" 
      android:layout_height="0.2dp"
      android:background="@color/theme_blue"/>
    <TextView android:layout_width="match_parent"
      android:layout_height="wrap_content"
      android:padding="8dp"
      android:gravity="center"
      android:textColor="@color/theme_blue"
      android:text="相冊(cè)"/>
  </LinearLayout>

  <RelativeLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_marginTop="5dp"
    android:padding="1dp">
    <Button
      android:id="@+id/btn_cancle"
      android:layout_width="match_parent"
      android:layout_height="wrap_content"
      android:gravity="center"
      android:padding="8dp"
      android:textColor="@color/theme_blue"
      android:background="@drawable/shape_info_bg"
      android:text="取消" />
  </RelativeLayout>
</LinearLayout>

彈出方法和方式一相似,不過(guò)不用再監(jiān)聽(tīng)popupWindow的退出事件

/**
 * 彈出底部對(duì)話(huà)框,達(dá)到背景背景透明效果
 * 
 * 實(shí)現(xiàn)原理:彈出一個(gè)全屏popupWindow,將Gravity屬性設(shè)置bottom,根背景設(shè)置為一個(gè)半透明的顏色,
 * 彈出時(shí)popupWindow的半透明效果背景覆蓋了在Activity之上 給人感覺(jué)上是popupWindow彈出后,背景變成半透明
 */
public void openPop2(View view) {
  View popView = LayoutInflater.from(mContext).inflate(
      R.layout.pop_bottom_alpha, null);
  View rootView = findViewById(R.id.root_main); // 當(dāng)前頁(yè)面的根佈局
  final PopupWindow popupWindow = new PopupWindow(popView,
      LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);

  // 設(shè)置彈出動(dòng)畫(huà)
  popupWindow.setAnimationStyle(R.style.AnimationFadeBottom);
  popupWindow.setBackgroundDrawable(new BitmapDrawable());
  // 顯示在根佈局的底部
  popupWindow.showAtLocation(rootView, Gravity.BOTTOM | Gravity.LEFT, 0,
      0);
}

以上就是本文的全部?jī)?nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持創(chuàng)新互聯(lián)。

網(wǎng)站名稱(chēng):iOS實(shí)現(xiàn)底部彈出PopupWindow效果iOS改變背景透明效果
當(dāng)前網(wǎng)址:http://aaarwkj.com/article2/gpgeic.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供網(wǎng)站策劃品牌網(wǎng)站制作、面包屑導(dǎo)航自適應(yīng)網(wǎng)站、關(guān)鍵詞優(yōu)化、電子商務(wù)

廣告

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

外貿(mào)網(wǎng)站建設(shè)
高清国语对白刺激av在线播放| 国产婷婷精品一区二区| 深夜释放自己污在线看| 小骚货操死你视频在线观看| 亚洲一区二区三区在线播| 亚洲精品在线观看午夜福利| 亚洲中文字幕永久免费| 国产一区中文字幕在线| 亚洲五月婷婷久久综合| 欧美性极品少妇精品网站| 国产二区日韩成人精品| 国产精品一区二在线观看| av中文字幕在线激情| 日韩在线免费色视频| 超碰97精品在线观看| 亚洲综合偷拍欧美一区日韩| 97视频在线观看观看| 97国产在线视频观看| 亚洲中文字幕高清无二区| 日本亚洲欧美男人的天堂| 国产三级系列在线观看| 日本在线中文字幕乱码| 久久青草精品欧美日韩精品| 成人欧美黑人一区二区| 日本高清加勒比免费在线| 欧美久久久久综合一区| 青青草成人免费在线公开视频| 激情四射五月天亚洲婷婷| 日本成熟妇高潮视频在线观看不卡| 91九色最新国产在线| 日本加勒比系列在线视频| 亚洲成熟中老妇女视频| 久久精品国产精品亚洲片| 免费一区二区三区黄色| 中文字幕日韩精品国产| 亚洲天堂国产中文在线| 色吊丝日韩在线观看| 欧美成人极品一区二区三区| 亚洲精品有码在线观看| 91天美精东果冻麻豆| 欧美日韩国产激情高清|