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

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

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

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

效果圖:

MainActivity.java頁面核心代碼:

protected void onCreate(Bundle savedInstanceState) {

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

  //創(chuàng)建廣播
  //InnerRecevier innerReceiver = new InnerRecevier();
  //動態(tài)注冊廣播
  //IntentFilter intentFilter = new IntentFilter(Intent.ACTION_CLOSE_SYSTEM_DIALOGS);
  //啟動廣播
  //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 實例,200,LayoutParams.MATCH_PARENT 分別是寬高
  popupWindow = new PopupWindow(popipWindow_view,300, ViewGroup.LayoutParams.MATCH_PARENT,true);
//設置動畫效果
  popupWindow.setAnimationStyle(R.style.AnimationFade);
  //點擊其他地方消失
  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實例*/

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="點擊彈出左菜單" android:layout_width="fill_parent"
  android:layout_height="wrap_content" />
</FrameLayout>

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

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

相關文章

最新評論

金塔县| 洛南县| 特克斯县| 大化| 个旧市| 武强县| 屏边| 高雄市| 古田县| 衡阳市| 合阳县| 东安县| 老河口市| 阳西县| 林周县| 招远市| 额济纳旗| 区。| 阿拉尔市| 定边县| 岳西县| 肇源县| 红原县| 五台县| 泸西县| 买车| 舞钢市| 大城县| 罗江县| 仙居县| 额敏县| 家居| 古浪县| 姜堰市| 五河县| 丹阳市| 五大连池市| 苍溪县| 佛冈县| 庆元县| 久治县|