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

Android開發(fā)之PopupWindow創(chuàng)建彈窗、對話框的方法詳解

 更新時間:2019年03月15日 11:41:45   作者:水中魚之1999  
這篇文章主要介紹了Android開發(fā)之PopupWindow創(chuàng)建彈窗、對話框的方法,結(jié)合實例形式詳細(xì)分析了Android使用PopupWindow創(chuàng)建對話框相關(guān)操作技巧,需要的朋友可以參考下

本文實例講述了Android開發(fā)之PopupWindow創(chuàng)建彈窗、對話框的方法。分享給大家供大家參考,具體如下:

簡介:

PopupWindow 可創(chuàng)建類似對話框風(fēng)格的窗口

效果:

使用方法:

使用PopupWindow 創(chuàng)建對話框風(fēng)格的串口秩序如下兩步即可:

1. PopupWindow 的構(gòu)造器創(chuàng)建PopupWindow對象

2. PopupWindow 的showAsDropDown() 將其顯示效果設(shè)置為下拉顯示

3. PopupWindow 的showAtLoacation() 方法將PopupWindow() 在指定位置顯示出來

下拉顯示效果:

具體實現(xiàn)方法:

public class MainActivity extends Activity {
  private PopupWindow popupWindow;
  private View root;
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    root = this.getLayoutInflater().inflate(R.layout.cell,null);//add cell.xml above you mainActivity window
    popupWindow = new PopupWindow(root,560,700);//create a popupWindow object
    root.findViewById(R.id.button01).setOnClickListener(new View.OnClickListener() {
      @Override
      public void onClick(View v) {
        //close the popupWindow
        popupWindow.dismiss();
      }
    });
  }
  public void send(View source){
    //set the location of PopupWindow
    popupWindow.showAtLocation(findViewById(R.id.send),Gravity.CENTER,20,20);//you can remove this effect
    //Use DropDown way to display
    popupWindow.showAsDropDown(root);
  }
}

mainActivity的布局文件:

<?xml version="1.0" encoding="utf-8" ?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
  android:id="@+id/idtatabHost"
  android:layout_width="match_parent"
  android:layout_height="match_parent"
  android:layout_weight="1">
  <Button
    android:id="@+id/send"
    android:onClick="send"
    android:text="點我一下 有驚喜(嚇) 。。。"
    android:layout_width="match_parent"
    android:layout_height="wrap_content" />
</LinearLayout>

/layout/cell.xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
  android:id="@+id/cell"
  xmlns:android="http://schemas.android.com/apk/res/android"
  android:layout_width="wrap_content"
  android:layout_height="wrap_content"
  android:orientation="vertical">
  <ImageView
    android:layout_width="match_parent"
    android:layout_height="0dp"
    android:layout_weight="9"
    android:src="@drawable/wechat"
    android:scaleType="fitXY"/>
  <Button
    android:id="@+id/button01"
    android:layout_width="match_parent"
    android:layout_height="0dp"
    android:layout_weight="1"
    android:background="#ffffffff"
    android:text="Close"
    android:textSize="15dp"/>
</LinearLayout>

更多關(guān)于Android相關(guān)內(nèi)容感興趣的讀者可查看本站專題:《Android開發(fā)入門與進(jìn)階教程》、《Android調(diào)試技巧與常見問題解決方法匯總》、《Android基本組件用法總結(jié)》、《Android視圖View技巧總結(jié)》、《Android布局layout技巧總結(jié)》及《Android控件用法總結(jié)

希望本文所述對大家Android程序設(shè)計有所幫助。

相關(guān)文章

  • android實現(xiàn)支付寶咻一咻的幾種思路方法

    android實現(xiàn)支付寶咻一咻的幾種思路方法

    本篇文章主要介紹了android實現(xiàn)支付寶咻一咻的幾種思路方法,詳解的介紹了幾種實現(xiàn)咻一咻的思路和方法,有需要的可以了解一下。
    2016-11-11
  • Android編程實現(xiàn)圖片拍照剪裁的方法

    Android編程實現(xiàn)圖片拍照剪裁的方法

    這篇文章主要介紹了Android編程實現(xiàn)圖片拍照剪裁的方法,涉及Android調(diào)用裁剪工具操作圖片的相關(guān)技巧,具有一定參考借鑒價值,需要的朋友可以參考下
    2015-12-12
  • Android開發(fā)實現(xiàn)圖片圓角的方法

    Android開發(fā)實現(xiàn)圖片圓角的方法

    這篇文章主要介紹了Android開發(fā)實現(xiàn)圖片圓角的方法,涉及Android針對圖形圖像的相關(guān)操作技巧,需要的朋友可以參考下
    2016-10-10
  • Android Rsa數(shù)據(jù)加解密的介紹與使用示例

    Android Rsa數(shù)據(jù)加解密的介紹與使用示例

    RSA是第一個既能用于數(shù)據(jù)加密也能用于數(shù)字簽名的算法。它易于理解和操作,也很流行。想起自己曾經(jīng)使用過的Rsa非對稱加密算法,閑下來總結(jié)一下。方便自己和大家以后使用的時候參考借鑒。下面來一起看看吧。
    2016-09-09
  • Flutter搞定寬高不統(tǒng)一布局開發(fā)的方法詳解

    Flutter搞定寬高不統(tǒng)一布局開發(fā)的方法詳解

    我們在開發(fā)移動端界面的時候,經(jīng)常會遇到一組尺寸不一的組件需要作為同一組展示,所以本文就將利用Wrap組件搞定寬高不統(tǒng)一布局開發(fā),需要的可以參考一下
    2023-06-06
  • 使用Docker來加速構(gòu)建Android應(yīng)用的基本部署思路解析

    使用Docker來加速構(gòu)建Android應(yīng)用的基本部署思路解析

    這篇文章主要介紹了使用Docker來加速構(gòu)建Android應(yīng)用的部署思路解析,在服務(wù)器中通過Docker鏡像來獲得更高效的開發(fā)和測試流程,需要的朋友可以參考下
    2016-01-01
  • android Handler詳細(xì)使用方法實例

    android Handler詳細(xì)使用方法實例

    本文主要介紹Android中Handler的簡單使用方法,Handler跟多線程,消息隊列聯(lián)系很緊密,在平常的實際程序開發(fā)中比較常見。本文分為4個簡單的例子來學(xué)校handler
    2013-11-11
  • Android getevent用法實例詳解

    Android getevent用法實例詳解

    這篇文章主要介紹了Android getevent用法實例詳解的相關(guān)資料,需要的朋友可以參考下
    2017-06-06
  • Flutter實現(xiàn)底部彈窗效果

    Flutter實現(xiàn)底部彈窗效果

    本文詳細(xì)講解了Flutter實現(xiàn)底部彈窗效果的方法,文中通過示例代碼介紹的非常詳細(xì)。對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧
    2021-11-11
  • 獲取Android界面性能數(shù)據(jù)的快捷方法

    獲取Android界面性能數(shù)據(jù)的快捷方法

    這篇文章主要介紹了獲取Android界面性能數(shù)據(jù)的快捷方法,幫助大家更好的理解和學(xué)習(xí)使用Android開發(fā),感興趣的朋友可以了解下
    2021-04-04

最新評論