最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

Android PopupWindow實(shí)現(xiàn)左側(cè)彈窗效果

 更新時(shí)間:2017年10月24日 15:27:18   作者:劉白超  
這篇文章主要為大家詳細(xì)介紹了Android PopupWindow實(shí)現(xiàn)左側(cè)彈窗效果,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下

本文實(shí)例為大家分享了Android PopupWindow實(shí)現(xiàn)左側(cè)彈窗的具體代碼,供大家參考,具體內(nèi)容如下

效果圖:

MainActivity.java頁面核心代碼:

protected void onCreate(Bundle savedInstanceState) {

  super.onCreate(savedInstanceState);
  //在setContentView之前添加,未添加的話home鍵監(jiān)聽無效,設(shè)置窗體屬性
  this.getWindow().setFlags(0x80000000, 0x80000000);
  setContentView(R.layout.activity_main);

  //創(chuàng)建廣播
  //InnerRecevier innerReceiver = new InnerRecevier();
  //動(dòng)態(tài)注冊廣播
  //IntentFilter intentFilter = new IntentFilter(Intent.ACTION_CLOSE_SYSTEM_DIALOGS);
  //啟動(dòng)廣播
  //registerReceiver(innerReceiver, intentFilter);

  //外部網(wǎng)頁
  // init();

  //pop
  Button pop = (Button) findViewById(R.id.popButton);
  pop.setOnClickListener(popClick);
 }
 View.OnClickListener popClick = new View.OnClickListener() {
  @Override
  public void onClick(View v) {
   getPopupWindow();
   popupWindow.showAtLocation(v, Gravity.LEFT,0,0);
  }
 };
 /*創(chuàng)建PopupWindow*/
 protected void initPopupWindow(){
  //獲取自定義布局文件activity_pop_left.xml 布局文件
  final View popipWindow_view = getLayoutInflater().inflate(R.layout.activity_pop_left,null,false);
  //創(chuàng)建Popupwindow 實(shí)例,200,LayoutParams.MATCH_PARENT 分別是寬高
  popupWindow = new PopupWindow(popipWindow_view,300, ViewGroup.LayoutParams.MATCH_PARENT,true);
//設(shè)置動(dòng)畫效果
  popupWindow.setAnimationStyle(R.style.AnimationFade);
  //點(diǎn)擊其他地方消失
  popipWindow_view.setOnTouchListener(new View.OnTouchListener() {
   @Override
   public boolean onTouch(View v, MotionEvent event) {
    if (popipWindow_view != null && popipWindow_view.isShown()) {
     popupWindow.dismiss();
     popupWindow = null;
    }
    return false;
   }
  });
  popupWindow.setBackgroundDrawable(new ColorDrawable(0));
  Button button1 = (Button) popipWindow_view.findViewById(R.id.button1);
  button1.setOnClickListener(new View.OnClickListener() {
   @Override
   public void onClick(View v) {
    Toast.makeText(getApplicationContext(),"全屏顯示",Toast.LENGTH_SHORT).show();
   }
  });
 }
/*獲取PopipWinsow實(shí)例*/

private void getPopupWindow(){
 if (null!=popupWindow){

  popupWindow.dismiss();
  return;
 }else {
  initPopupWindow();
 }
}

activity_main.xml頁面

<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
 xmlns:tools="http://schemas.android.com/tools"
 android:id="@+id/container"
 android:layout_width="match_parent"
 android:layout_height="match_parent"
 tools:context="com.example.x.MainActivity"
 tools:ignore="MergeRootFrame" >

 <WebView 
 android:layout_width="match_parent"
 android:layout_height="match_parent"
 android:id="@+id/webView"
 />
 <Button
  android:id="@+id/popButton"
  android:text="點(diǎn)擊彈出左菜單" android:layout_width="fill_parent"
  android:layout_height="wrap_content" />
</FrameLayout>

左側(cè)菜單需單獨(dú)設(shè)置一個(gè)xml頁面,style樣式自定義。

以上就是本文的全部內(nèi)容,希望對大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。

相關(guān)文章

最新評論

保德县| 鹤岗市| 元阳县| 乐都县| 崇左市| 盘锦市| 贡山| 潮州市| 禹州市| 皋兰县| 山西省| 镇巴县| 同江市| 锦屏县| 石景山区| 夹江县| 庆城县| 怀柔区| 亳州市| 鄢陵县| 辉南县| 金湖县| 奎屯市| 上林县| 蓝山县| 德清县| 洛南县| 额尔古纳市| 砚山县| 株洲县| 醴陵市| 安塞县| 北流市| 福海县| 连平县| 莆田市| 定襄县| 乳山市| 凉山| 九龙县| 调兵山市|