GVKun编程网logo

Android开发实现popupWindow弹出窗口自定义布局与位置控制方法(android popwindow在指定位置弹出)

28

本文将为您提供关于Android开发实现popupWindow弹出窗口自定义布局与位置控制方法的详细介绍,我们还将为您解释androidpopwindow在指定位置弹出的相关知识,同时,我们还将为您提

本文将为您提供关于Android开发实现popupWindow弹出窗口自定义布局与位置控制方法的详细介绍,我们还将为您解释android popwindow在指定位置弹出的相关知识,同时,我们还将为您提供关于android PopupWindow 和 Activity弹出窗口实现方式、Android PopupWindow 实现自定义菜单弹窗效果、Android PopupWindow实现右侧、左侧和底部弹出菜单、Android PopupWindow弹不出来(已解决)的实用信息。

本文目录一览:

Android开发实现popupWindow弹出窗口自定义布局与位置控制方法(android popwindow在指定位置弹出)

Android开发实现popupWindow弹出窗口自定义布局与位置控制方法(android popwindow在指定位置弹出)

本文实例讲述了Android开发实现popupWindow弹出窗口自定义布局与位置控制方法。分享给大家供大家参考,具体如下:

布局文件:

主布局文件:activity_main:

<?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:layout_width="match_parent"
  android:layout_height="match_parent"
  tools:context="com.example.bige.MainActivity"
  android:orientation="vertical">
  <LinearLayout
    android:layout_marginTop="10dp"
    android:layout_marginLeft="10dp"
    android:layout_marginRight="10dp"
    android:orientation="vertical"
    android:layout_width="match_parent"
    android:layout_height="wrap_content">
  <LinearLayout
    android:orientation="horizontal"
    android:layout_width="match_parent"
    android:layout_height="wrap_content">
    <Button
      android:textSize="20dp"
      android:paddingTop="10dp"
      android:gravity="left"
      android:layout_width="0dp"
      android:layout_height="match_parent"
      android:layout_weight="3"
      android:text="富乃宝山"
      android:background="#AAAAAA"/>
    <Button
      android:layout_marginRight="5dp"
      android:layout_marginLeft="5dp"
      android:background="#AAAAAA"
      android:layout_width="0dp"
      android:layout_height="wrap_content"
      android:layout_weight="1"
      android:text="0点"/>
    <Button
      android:id="@+id/num1"
      android:layout_width="0dp"
      android:layout_height="wrap_content"
      android:layout_weight="1"
      android:textColor="@android:color/white"
      android:background="#000000"
      android:text="1"/>
  </LinearLayout>
  <LinearLayout
    android:layout_marginTop="10dp"
    android:layout_width="match_parent"
    android:layout_height="wrap_content">
    <Button
      android:layout_width="0dp"
      android:layout_height="wrap_content"
      android:layout_weight="1"
      android:text="ビ`ル"
      android:background="#A4A4A4"
      android:layout_marginRight="3dp"/>
    <Button
      android:layout_width="0dp"
      android:layout_height="wrap_content"
      android:layout_weight="1"
      android:text="FD"
      android:background="#A4A4A4"
      android:layout_marginRight="3dp"
      />
    <Button
      android:layout_marginLeft="3dp"
      android:layout_marginRight="3dp"
      android:layout_width="0dp"
      android:layout_height="wrap_content"
      android:layout_weight="1"
      android:text="酎"
      android:background="#6FA5DB"/>
    <Button
      android:layout_width="0dp"
      android:layout_height="wrap_content"
      android:layout_weight="1"
      android:text="日本酒"
      android:background="#A4A4A4"/>
  </LinearLayout>
  <LinearLayout
    android:layout_marginTop="2dp"
    android:layout_width="match_parent"
    android:layout_height="wrap_content">
    <Button
      android:layout_width="0dp"
      android:layout_height="wrap_content"
      android:layout_weight="1"
      android:text="ソフト "
      android:background="#A4A4A4"
      android:layout_marginRight="3dp"/>
    <Button
      android:layout_width="0dp"
      android:layout_height="wrap_content"
      android:layout_weight="1"
      android:text="サワ` "
      android:background="#A4A4A4"
      android:layout_marginRight="3dp"
      />
    <Button
      android:layout_marginLeft="3dp"
      android:layout_marginRight="3dp"
      android:layout_width="0dp"
      android:layout_height="wrap_content"
      android:layout_weight="1"
      android:text="カクテル "
      android:background="#A4A4A4"/>
    <Button
      android:layout_width="0dp"
      android:layout_height="wrap_content"
      android:layout_weight="1"
      android:text="ワイン "
      android:background="#A4A4A4"/>
  </LinearLayout>
  <LinearLayout
    android:layout_marginTop="2dp"
    android:layout_width="match_parent"
    android:layout_height="wrap_content">
    <Button
      android:layout_width="0dp"
      android:layout_height="wrap_content"
      android:layout_weight="1"
      android:text="果g酒 "
      android:background="#A4A4A4"
      android:layout_marginRight="3dp"/>
    <Button
      android:layout_width="0dp"
      android:layout_height="wrap_content"
      android:layout_weight="1"
      android:text="ウイスキ` "
      android:background="#A4A4A4"
      android:layout_marginRight="3dp"
      />
    <Button
      android:layout_marginLeft="3dp"
      android:layout_marginRight="3dp"
      android:layout_width="0dp"
      android:layout_height="wrap_content"
      android:layout_weight="1"
      android:background="#A4A4A4"/>
    <Button
      android:layout_width="0dp"
      android:layout_height="wrap_content"
      android:layout_weight="1"
      android:background="#A4A4A4"/>
  </LinearLayout>
  <LinearLayout
    android:layout_marginTop="2dp"
    android:layout_width="match_parent"
    android:layout_height="wrap_content">
    <Button
      android:layout_width="0dp"
      android:layout_height="wrap_content"
      android:layout_weight="1"
      android:text="会席M行 "
      android:background="#A4A4A4"
      android:layout_marginRight="3dp"/>
    <Button
      android:layout_width="0dp"
      android:layout_height="wrap_content"
      android:layout_weight="1"
      android:text="パックM行 "
      android:background="#A4A4A4"
      android:layout_marginRight="3dp"
      />
    <Button
      android:layout_marginLeft="3dp"
      android:layout_marginRight="3dp"
      android:layout_width="0dp"
      android:layout_height="wrap_content"
      android:layout_weight="1"
      android:text="g品 "
      android:background="#A4A4A4"/>
    <Button
      android:layout_width="0dp"
      android:layout_height="wrap_content"
      android:layout_weight="1"
      android:background="#A4A4A4"/>
  </LinearLayout>
  <LinearLayout
    android:orientation="horizontal"
    android:layout_marginTop="2dp"
    android:layout_width="match_parent"
    android:layout_height="wrap_content">
    <Button
      android:layout_width="0dp"
      android:layout_height="wrap_content"
      android:layout_weight="1"
      android:text="ソフト "
      android:background="#A4A4A4"
      android:layout_marginRight="3dp"/>
    <Button
      android:layout_width="0dp"
      android:layout_height="wrap_content"
      android:layout_weight="1"
      android:text="サワ` "
      android:background="#A4A4A4"
      android:layout_marginRight="3dp"
      />
    <Button
      android:layout_marginLeft="3dp"
      android:layout_marginRight="3dp"
      android:layout_width="0dp"
      android:layout_height="wrap_content"
      android:layout_weight="1"
      android:text="カクテル "
      android:background="#A4A4A4"/>
    <Button
      android:layout_width="0dp"
      android:layout_height="wrap_content"
      android:layout_weight="1"
      android:text="ワイン "
      android:background="#A4A4A4"/>
  </LinearLayout>
  <LinearLayout
    android:layout_marginTop="10dp"
    android:layout_width="match_parent"
    android:layout_height="wrap_content">
    <Button
      android:layout_marginRight="3dp"
      android:layout_width="0dp"
      android:layout_height="wrap_content"
      android:layout_weight="1"
      android:background="#A4A4A4"
      android:text="ロック " />
    <Button
      android:layout_marginRight="3dp"
      android:layout_width="0dp"
      android:layout_height="wrap_content"
      android:layout_weight="1"
      android:background="#A4A4A4"
      android:text="水割り " />
    <Button
      android:layout_marginRight="3dp"
      android:layout_marginLeft="3dp"
      android:layout_width="0dp"
      android:layout_height="wrap_content"
      android:layout_weight="1"
      android:background="#A4A4A4"
      android:text="お瞍 " />
    <Button
      android:layout_width="0dp"
      android:layout_height="wrap_content"
      android:layout_weight="1"
      android:background="#A4A4A4"
      android:text="ソ`ダ割 " />
  </LinearLayout>
  <LinearLayout
    android:layout_marginTop="3dp"
    android:layout_width="match_parent"
    android:layout_height="wrap_content">
    <Button
      android:layout_marginRight="3dp"
      android:layout_width="0dp"
      android:layout_height="wrap_content"
      android:layout_weight="1"
      android:background="#A4A4A4" />
    <Button
      android:layout_marginRight="3dp"
      android:layout_width="0dp"
      android:layout_height="wrap_content"
      android:layout_weight="1"
      android:background="#A4A4A4" />
    <Button
      android:layout_marginRight="3dp"
      android:layout_marginLeft="3dp"
      android:layout_width="0dp"
      android:layout_height="wrap_content"
      android:layout_weight="1"
      android:background="#A4A4A4" />
    <Button
      android:layout_width="0dp"
      android:layout_height="wrap_content"
      android:layout_weight="1"
      android:background="#A4A4A4" />
  </LinearLayout>
  <LinearLayout
    android:layout_marginTop="3dp"
    android:layout_width="match_parent"
    android:layout_height="wrap_content">
    <Button
      android:layout_marginRight="3dp"
      android:layout_width="0dp"
      android:layout_height="wrap_content"
      android:layout_weight="1"
      android:background="#A4A4A4" />
    <Button
      android:layout_marginRight="3dp"
      android:layout_width="0dp"
      android:layout_height="wrap_content"
      android:layout_weight="1"
      android:background="#A4A4A4" />
    <Button
      android:layout_marginRight="3dp"
      android:layout_marginLeft="3dp"
      android:layout_width="0dp"
      android:layout_height="wrap_content"
      android:layout_weight="1"
      android:background="#A4A4A4" />
    <Button
      android:layout_width="0dp"
      android:layout_height="wrap_content"
      android:layout_weight="1"
      android:background="#A4A4A4" />
  </LinearLayout>
  <LinearLayout
    android:layout_marginTop="3dp"
    android:layout_width="match_parent"
    android:layout_height="wrap_content">
    <Button
      android:layout_marginRight="3dp"
      android:layout_width="0dp"
      android:layout_height="wrap_content"
      android:layout_weight="1"
      android:background="#A4A4A4" />
    <Button
      android:layout_marginRight="3dp"
      android:layout_width="0dp"
      android:layout_height="wrap_content"
      android:layout_weight="1"
      android:background="#A4A4A4" />
    <Button
      android:layout_marginRight="3dp"
      android:layout_marginLeft="3dp"
      android:layout_width="0dp"
      android:layout_height="wrap_content"
      android:layout_weight="1"
      android:background="#A4A4A4" />
    <Button
      android:layout_width="0dp"
      android:layout_height="wrap_content"
      android:layout_weight="1"
      android:background="#A4A4A4" />
  </LinearLayout>
  <LinearLayout
    android:layout_marginTop="3dp"
    android:layout_width="match_parent"
    android:layout_height="wrap_content">
    <Button
      android:layout_marginRight="3dp"
      android:layout_width="0dp"
      android:layout_height="wrap_content"
      android:layout_weight="1"
      android:background="#A4A4A4"
      android:text=" " />
    <Button
      android:layout_marginRight="3dp"
      android:layout_width="0dp"
      android:layout_height="wrap_content"
      android:layout_weight="1"
      android:background="#A4A4A4" />
    <Button
      android:layout_marginRight="3dp"
      android:layout_marginLeft="3dp"
      android:layout_width="0dp"
      android:layout_height="wrap_content"
      android:layout_weight="1"
      android:background="#A4A4A4" />
    <Button
      android:layout_width="0dp"
      android:layout_height="wrap_content"
      android:layout_weight="1"
      android:background="#A4A4A4" />
  </LinearLayout>
  </LinearLayout>
  <LinearLayout
    android:orientation="horizontal"
    android:layout_marginTop="10dp"
    android:layout_marginBottom="0dp"
    android:background="#5399D9"
    android:layout_width="match_parent"
    android:layout_height="wrap_content">
    <Button
      android:layout_marginBottom="3dp"
      android:layout_marginTop="3dp"
      android:layout_marginLeft="15dp"
      android:layout_marginRight="3dp"
      android:background="#FFC727"
      android:layout_width="0dp"
      android:layout_height="wrap_content"
      android:layout_weight="1"
      android:text="AC"/>
    <Button
      android:layout_marginBottom="3dp"
      android:layout_marginTop="3dp"
      android:layout_marginRight="3dp"
      android:background="#6DB040"
      android:layout_width="0dp"
      android:layout_height="wrap_content"
      android:layout_weight="1"
      android:text="NG"/>
    <Button
      android:layout_marginBottom="3dp"
      android:layout_marginTop="3dp"
      android:layout_marginRight="3dp"
      android:background="#6DB040"
      android:layout_width="0dp"
      android:layout_height="wrap_content"
      android:layout_weight="1"
      android:text="後"/>
    <Button
      android:layout_marginBottom="3dp"
      android:layout_marginTop="3dp"
      android:layout_marginRight="3dp"
      android:background="#6DB040"
      android:layout_width="0dp"
      android:layout_height="wrap_content"
      android:layout_weight="1"
      android:text="急"/>
    <Button
      android:layout_marginBottom="3dp"
      android:layout_marginTop="3dp"
      android:layout_marginRight="3dp"
      android:background="#6DB040"
      android:layout_width="0dp"
      android:layout_height="wrap_content"
      android:layout_weight="1"
      android:text="▲"/>
    <Button
      android:layout_marginBottom="3dp"
      android:layout_marginTop="3dp"
      android:layout_marginRight="15dp"
      android:background="#FFC727"
      android:layout_width="0dp"
      android:layout_height="wrap_content"
      android:layout_weight="1"
      android:text="_J"/>
  </LinearLayout>
</LinearLayout>

弹出布局设置:

number:

<?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:orientation="vertical"
  android:id="@+id/number"
  android:background="#FCFCFC">
  <LinearLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content">
    <EditText
      android:gravity="right"
      android:background="@drawable/edittext"
      android:layout_width="match_parent"
      android:layout_height="40dp"
      android:hint="0"
      android:textSize="35dp"
      />
  </LinearLayout>
  <LinearLayout
    android:orientation="horizontal"
    android:layout_width="match_parent"
    android:layout_height="wrap_content">
    <Button
      android:layout_marginRight="1dp"
      android:background="@drawable/button"
      android:layout_width="0dp"
      android:layout_height="wrap_content"
      android:layout_weight="1"
      android:text="7" />
    <Button
      android:layout_marginRight="1dp"
      android:background="@drawable/button"
      android:layout_width="0dp"
      android:layout_height="wrap_content"
      android:layout_weight="1"
      android:text="8" />
    <Button
      android:background="@drawable/button"
      android:layout_width="0dp"
      android:layout_height="wrap_content"
      android:layout_weight="1"
      android:text="9" />
  </LinearLayout>
  <LinearLayout
    android:layout_marginTop="1dp"
    android:orientation="horizontal"
    android:layout_width="match_parent"
    android:layout_height="wrap_content">
    <Button
      android:layout_marginRight="1dp"
      android:background="@drawable/button"
      android:layout_width="0dp"
      android:layout_height="wrap_content"
      android:layout_weight="1"
      android:text="4" />
    <Button
      android:layout_marginRight="1dp"
      android:background="@drawable/button"
      android:layout_width="0dp"
      android:layout_height="wrap_content"
      android:layout_weight="1"
      android:text="5" />
    <Button
      android:background="@drawable/button"
      android:layout_width="0dp"
      android:layout_height="wrap_content"
      android:layout_weight="1"
      android:text="6" />
  </LinearLayout>
  <LinearLayout
    android:orientation="horizontal"
    android:layout_width="match_parent"
    android:layout_height="wrap_content">
    <Button
      android:layout_marginRight="1dp"
      android:background="@drawable/button"
      android:layout_width="0dp"
      android:layout_height="wrap_content"
      android:layout_weight="1"
      android:text="1" />
    <Button
      android:layout_marginRight="1dp"
      android:background="@drawable/button"
      android:layout_width="0dp"
      android:layout_height="wrap_content"
      android:layout_weight="1"
      android:text="2" />
    <Button
      android:background="@drawable/button"
      android:layout_width="0dp"
      android:layout_height="wrap_content"
      android:layout_weight="1"
      android:text="3" />
  </LinearLayout>
  <LinearLayout
    android:orientation="horizontal"
    android:layout_width="match_parent"
    android:layout_height="wrap_content">
    <Button
      android:layout_marginRight="1dp"
      android:background="@drawable/button"
      android:layout_width="0dp"
      android:layout_height="wrap_content"
      android:layout_weight="1"
      android:text="0" />
    <Button
      android:layout_marginRight="1dp"
      android:background="@drawable/button"
      android:layout_width="0dp"
      android:layout_height="wrap_content"
      android:layout_weight="1"
      android:text="→" />
    <Button
      android:background="@drawable/button"
      android:layout_width="0dp"
      android:layout_height="wrap_content"
      android:layout_weight="1"
      android:text="C" />
  </LinearLayout>
  <LinearLayout
    android:orientation="horizontal"
    android:layout_width="match_parent"
    android:layout_height="wrap_content">
    <Button
      android:layout_width="0dp"
      android:layout_height="wrap_content"
      android:layout_weight="1"
      android:background="@drawable/button"
      android:text="" />
    <Button
      android:layout_width="0dp"
      android:layout_height="wrap_content"
      android:layout_weight="1"
      android:background="@drawable/button"
      android:text="OK" />
  </LinearLayout>
</LinearLayout>

MainActivity布局:

package com.example.bige;
import android.support.v4.widget.PopupWindowCompat;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.Gravity;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.widget.Button;
import android.widget.PopupWindow;
import android.widget.Toast;
public class MainActivity extends AppCompatActivity {
  Button mbtn;
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    requestwindowFeature(Window.FEATURE_NO_TITLE);
    getwindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,WindowManager.LayoutParams.FLAG_FULLSCREEN);
    setContentView(R.layout.activity_main);
    View root = this.getLayoutInflater().inflate(R.layout.number,null);
    //设置弹出布局自适应大小
    final PopupWindow popup = new PopupWindow(root,WindowManager.LayoutParams.WRAP_CONTENT,WindowManager.LayoutParams.WRAP_CONTENT);
    mbtn = (Button) findViewById(R.id.num1);
    mbtn.setonClickListener(new View.OnClickListener() {
      @Override
      public void onClick(View view) {
        // popup.isShowing();
        Toast.makeText(MainActivity.this,"hh",Toast.LENGTH_SHORT).show();
         //控制pupup弹出位置在父布局的中间显示
         //四个参数分别表示,要参考的控件view,相对位置,后边两个参数int x,int y表示偏移
        popup.showAtLocation(view,Gravity.CENTER,0);
      }
    });
  }
}

更多关于Android相关内容感兴趣的读者可查看本站专题:《Android窗口相关操作技巧总结》、《Android开发入门与进阶教程》、《Android调试技巧与常见问题解决方法汇总》、《Android基本组件用法总结》、《Android视图View技巧总结》、《Android布局layout技巧总结》及《Android控件用法总结》

希望本文所述对大家Android程序设计有所帮助。

android PopupWindow 和 Activity弹出窗口实现方式

本人小菜一个。目前只见过两种弹出框的实现方式,第一种是最常见的PopupWindow,第二种也就是Activity的方式是前几天才见识过。感觉很霸气哦。没想到,activity也可以做伪窗口。
先贴上最常见的方法,主要讲activity的方法。
一、弹出PopupWindow


复制代码 代码如下:

/**
* 弹出menu菜单
*/
public void menu_press(){
if(!menu_display){
//获取LayoutInflater实例
inflater = (LayoutInflater)this.getSystemService(LAYOUT_INFLATER_SERVICE);
//这里的main布局是在inflate中加入的哦,以前都是直接this.setContentView()的吧?呵呵
//该方法返回的是一个View的对象,是布局中的根
layout = inflater.inflate(R.layout.main_menu,null);
//下面我们要考虑了,我怎样将我的layout加入到PopupWindow中呢???很简单
menuWindow = new PopupWindow(layout,LayoutParams.FILL_PARENT,LayoutParams.WRAP_CONTENT); //后两个参数是width和height
//menuWindow.showAsDropDown(layout); //设置弹出效果
//menuWindow.showAsDropDown(null,layout.getHeight());
//设置如下四条信息,当点击其他区域使其隐藏,要在show之前配置
menuWindow.setFocusable(true);
menuWindow.setoutsidetouchable(true);
menuWindow.update();
menuWindow.setBackgroundDrawable(new BitmapDrawable());
mClose = (LinearLayout)layout.findViewById(R.id.menu_close);
menuWindow.showAtLocation(this.findViewById(R.id.schoolmain),Gravity.BottOM|Gravity.CENTER_HORIZONTAL,50); //设置layout在PopupWindow中显示的位置
//如何获取我们main中的控件呢?也很简单
mMainbtn = (LinearLayout)layout.findViewById(R.id.menu_main_btn);
mHistorybtn = (LinearLayout) layout.findViewById(R.id.menu_history_btn);
mHelpbtn = (LinearLayout) layout.findViewById(R.id.menu_help_btn);
//下面对每一个Layout进行单击事件的注册吧。。。
//比如单击某个MenuItem的时候,他的背景色改变
//事先准备好一些背景图片或者颜色
mMainbtn.setonClickListener (new View.OnClickListener() {
@Override
public void onClick(View arg0) {
mywebView.loadUrl(URL);
menuWindow.dismiss(); //响应点击事件之后关闭Menu
}
});
mHelpbtn.setonClickListener (new View.OnClickListener() {
@Override
public void onClick(View arg0) {
mywebView.loadUrl(URL);
menuWindow.dismiss(); //响应点击事件
}
});
mHistorybtn.setonClickListener (new View.OnClickListener() {
@Override
public void onClick(View arg0) {
mywebView.loadUrl(URL);
menuWindow.dismiss(); //响应点击事件
}
});
menu_display = true;
}else{
//如果当前已经为显示状态,则隐藏起来
menuWindow.dismiss();
menu_display = false;
}
}
public void back_press(){
if(menu_display){ //如果 Menu已经打开 ,先关闭Menu
menuWindow.dismiss();
menu_display = false;
}
else {
Intent intent = new Intent();
intent.setClass(MainActivity.this,Exit.class);
startActivity(intent);
}
}

这种方法很简单,要注意的是如果要想点击其他地方使其隐藏,要在show设置四条属性如下:
// 使其聚焦
mPopupWindow.setFocusable(true);
// 设置允许在外点击消失
mPopupWindow.setoutsidetouchable(true);
//刷新状态
mPopupWindow.update();
//点back键和其他地方使其消失,设置了这个才能触发Ondismisslistener ,设置其他控件变化等操作
mPopupWindow.setBackgroundDrawable(new BitmapDrawable());
二、Activity做伪弹窗

 

本人感觉这个很先进啊。恕我冒犯,我只这里直接写上牛人的代码。此牛人写的是防微信的demo。做的相当好,我在后面附上CSDN免费下载链接。
先贴上java代码――Exit.java
package cn.buaa.myweixin;
import android.app.Activity;
import android.os.Bundle;
import android.view.MotionEvent;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.LinearLayout;
import android.widget.Toast;
public class Exit extends Activity {
private LinearLayout layout;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.exit_dialog);
layout=(LinearLayout)findViewById(R.id.exit_layout);
layout.setonClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
// Todo Auto-generated method stub
Toast.makeText(getApplicationContext(),"提示:点击窗口外部关闭窗口!",
Toast.LENGTH_SHORT).show();
}
});
}
@Override
public boolean onTouchEvent(MotionEvent event){
finish();
return true;
}
public void exitbutton1(View v) {
this.finish();
}
public void exitbutton0(View v) {
this.finish();
MainWeixin.instance.finish();//关闭Main 这个Activity
}
}
附上布局文件:exit_dialog.xml
复制代码 代码如下:

View Code
<?xml version="1.0" encoding="UTF-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/exit_layout"
android:layout_width="280dp"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:orientation="vertical"
android:background="@drawable/confirm_dialog_bg2" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="4dp"
android:padding="5dp"
android:textColor="#333"
android:textSize="20sp"
android:text="退出微信" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#333"
android:layout_marginTop="1dp"
android:padding="10dp"
android:textSize="16sp"
android:gravity="center_horizontal"
android:text="退出后,你将收不到新的消\n息.确定要退出?" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="33dp"
android:layout_marginBottom="8dp"
>
<Button
android:id="@+id/exitBtn0"
android:layout_width="110dp"
android:layout_height="wrap_content"
android:text="是"
android:textSize="16sp"
android:textColor="#fff"
android:background="@drawable/btn_style_green"
android:gravity="center"
android:onClick="exitbutton0"
/>
<Button
android:id="@+id/exitBtn1"
android:layout_width="110dp"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:text="否"
android:textSize="16sp"
android:textColor="#333"
android:background="@drawable/btn_style_white"
android:gravity="center"
android:onClick="exitbutton1"
/>
</LinearLayout>
</LinearLayout>

分析,弹出exit这个框很简单,本身就是activity,在主界面用startavtivity等方法像普通activity启动。
关键是如何做到点击其他地方退出和如何关闭程序。
、点击其他地方退出,只要监听OnClickListener让所有的点击都退出就行了(除了xml中指定按钮事件之外)。
、退出主程序。只要在出程序中将主程序自己设置成静态对象,在外部调用即可 public static MainWeixin instance=null;
上面的布局和activity并不能将activity的窗体展现在主界面之上,看起来像个弹出框。下面是弹出框的styles配置:
复制代码 代码如下:

<style name="MyDialogStyle">
<item name="android:windowBackground">@android:color/transparent</item>
<item name="android:windowFrame">@null</item>
<item name="android:windowNoTitle">true</item>
<item name="android:windowIsFloating">true</item>
<item name="android:windowIsTranslucent">true</item>
<item name="android:windowContentOverlay">@null</item>
<item name="android:windowAnimationStyle">@android:style/Animation.Dialog</item>
<item name="android:backgroundDimEnabled">true</item>
</style>

下面我们来分析一下这个布局的含义及重点:
重点1、<item name="android:windowBackground">@android:color/transparent</item>窗口背景色
重点2、<item name="android:windowFrame">@null</item>Dialog的windowFrame框为无
重点4、<item name="android:windowIsFloating">true</item>是否浮现在activity之上
重点5、<item name="android:windowIsTranslucent">true</item>窗口是否半透明――是(与第一条配合使用)
重点6、<item name="android:windowAnimationStyle">@android:style/Animation.Dialog</item>窗口弹出效果
重点7、<item name="android:backgroundDimEnabled">true</item> 是否允许背景模糊
重点8、<item name="android:windowContentOverlay">@null</item>这个不设置的话,可能会出现边框黑线
以上代码都是牛人们的功劳,我拿来做一分析,给更多需要的朋友。
我在众多牛人的指引下一步步成长,感谢牛人们。

Android PopupWindow 实现自定义菜单弹窗效果

先看最终效果图:
请输入图片描述
原理一个将PopupWindow绑在一个TextView上,处理TextView点击事件来弹框,右边EditText实现输入框,把EditText拿上来是因为在实习过程中碰到不少细节问题。代码:
main.xml //主页面布局

<RelativeLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:background="@color/bgtitlebar"
    android:orientation="horizontal"
    android:padding="10dp" >

    <LinearLayout
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:gravity="center_vertical" >

        <Button
            android:id="@+id/btn_header_back"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:background="@drawable/btn_back"
            android:onClick="back" />
    </LinearLayout>

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_centerHorizontal="true"
        android:layout_centerVertical="true"
        android:layout_marginLeft="10dp"
        android:text="@string/txt_search"
        android:textSize="18sp" />
</RelativeLayout>

<RelativeLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:background="@drawable/bg_divide_line_search" >

    <LinearLayout
        android:id="@+id/ll_search_txt"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginLeft="10dp"
        android:layout_marginTop="6dp"
        android:background="@drawable/bg_tv_search_category" >//因为一个控件只能有一张背景图片,所以把“资讯”的另一张背景图片放在布局上

        <TextView
            android:id="@+id/search_category"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginBottom="3dp"
            android:layout_marginLeft="10dp"
            android:layout_marginTop="3dp"
            android:clickable="true"
            android:drawableRight="@drawable/bg_tv_search_pop"//这个属性可将图片放在控件的左侧
            android:text="@string/message"
            android:textColor="@color/blue"
            android:textSize="19sp" />
    </LinearLayout>

    <LinearLayout
        android:layout_width="200dp"
        android:layout_height="wrap_content"
        android:layout_marginLeft="18dp"
        android:layout_toRightOf="@id/ll_search_txt"
        android:background="@drawable/bg_edt_search"
        android:layout_marginTop="9dp"
        >
        <EditText
            android:id="@+id/input_search_cagegory"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:paddingLeft="5dp"
            android:background="@drawable/bg_edt_search"
            android:ems="10"
            android:drawableLeft="@drawable/bg_edt_search_icon  
            android:hint="@string/input_search_txt"
            android:singleLine="true" />
    </LinearLayout>
</RelativeLayout>

popup_item.xml // PopupWindow 弹框内容,这里只是简单的TextView,涉及ListView的话要复杂些

<?xml version="1.0" encoding="utf-8"?>

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical" >
<TextView
    android:id="@+id/search_picture"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="@string/picture"
    android:clickable="true"
    android:textSize="19sp"
    android:background="@drawable/bg_search_picture"
    />
 <TextView
    android:id="@+id/search_video"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="@string/video"
    android:clickable="true"
    android:textSize="19sp"
    android:background="@drawable/bg_search_video"
    />
  <TextView
    android:id="@+id/search_message"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="@string/message"
    android:clickable="true"
    android:textSize="19sp"
    android:background="@drawable/bg_search_message"
    />


main.java

public class SearchActivity extends Activity {
private PopupWindow window = null;
private LayoutInflater inflater;
private TextView txt_choosecategory;
private TextView message;
private TextView picture;
private TextView video;
private EditText edt_inputcagegory;
private Button btn_header_back;
private View view;
private ListView listView;
private String return_result;
private String category_id;
private String keyword;
    private SearchTask searchTask;
private String category;
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_search);
    initHeader();
    initBodyer();
}

private boolean isInput() {
    if (isNullorSpace(edt_inputcagegory.getText().toString())) {
        return false;
    }
    return true;
}

private void initBodyer() {
//      final InputMethodManager imm = (InputMethodManager)      //getSystemService(Context.INPUT_METHOD_SERVICE);
    txt_choosecategory = (TextView) findViewById(R.id.search_category);
    edt_inputcagegory = (EditText) findViewById(R.id.input_search_cagegory);
    edt_inputcagegory.setImeOptions(EditorInfo.IME_ACTION_SEARCH); //这行代码的作用是把键盘右下角的“回车”键变成“搜索”键
    txt_choosecategory.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            if (window != null) {  //一定要先判断是否为空!
                if (window.isShowing()) {//isShowing()方法判断当前是否已经弹窗,返回true则关闭PopupWindow
                    window.dismiss();
                    window = null;
                }
            } else {
                showWindow();实际这里是实现点击一次弹出PopupWindow,再点击一次关闭掉。
            }

        }
    });
    edt_inputcagegory
            .setOnEditorActionListener(new OnEditorActionListener() {

                @Override
                public boolean onEditorAction(TextView v, int actionId,
                        KeyEvent event) {//对键盘的搜索键监听事件
                    if (actionId == EditorInfo.IME_ACTION_SEARCH) {
                        if (isInput()) {
                            search();
                        } else {
//edt_inputcagegory.requestFocus();                                                          //imm.showSoftInputFromInputMethod(edt_inputcagegory.getWindowToken(), 0);
Toast.makeText(Main.this,"搜索内容不能为空",Toast.LENGH_SHORT);                         

                        }
                    }

                    return false;
                }
            });
}

private void initHeader() {
    btn_header_back = (Button) findViewById(R.id.btn_header_back);
    btn_header_back.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {

            finish();
        }
    });
}
    private boolean isNullorSpace(String str) {
    if (!"".equals(str.trim()) & (str != null))
        return false;
    return true;
}

private void search() {
    //Handle search
}

private void showWindow() {
    inflater = (LayoutInflater) this
            .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    view = inflater.inflate(R.layout.item_search_category, null, false);//加载布局
    message = (TextView) view.findViewById(R.id.search_message);
    video = (TextView) view.findViewById(R.id.search_video);
    picture = (TextView) view.findViewById(R.id.search_picture);
    message.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            txt_choosecategory.setText(R.string.message);  //错误代码
            window.dismiss();
            window = null;
        }
    });
    video.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            txt_choosecategory.setText(R.string.video);//错误代码
            window.dismiss();
            window = null;
        }
    });
    picture.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            txt_choosecategory.setText(R.string.picture);//错误代码
            window.dismiss();
            window = null;
        }
    });
    if (window == null) {
        window = new PopupWindow(view, LayoutParams.WRAP_CONTENT,
                LayoutParams.WRAP_CONTENT);//创建PopupWindow,第一个参数是将要展示的内容布局,第二、三个是布局大小(LayoutParamas.WRAP_CONTENT,LayoutParams.WRAP_CONTENT要求API >=11)
    }
    // int[] location = new int[2];
    // window.showAsDropDown(txt_choosecategory);
    // window.showAtLocation(txt_choosecategory, Gravity.NO_GRAVITY,
    // location[0], location[1]);
    window.showAtLocation(txt_choosecategory, Gravity.NO_GRAVITY, 15, 160);//设置PopupWindow位置,第一个参数是指定PopupWindow依附的View,第二个是坐标偏移量相对的起始点,Gravity.NO_GRAVITY= Gravity.LEFT | Gravity.TOP,最后两个是偏移量,这个写死了应该对屏幕适配不太好,而且很麻烦囧,暂时还没找到方便的方法..欢迎大侠指路.
}

需要注意的是:1.本人一开始用PopupWindow就曾经报错: "Unable to add window -- token null is not valid",原因在stackoverflow上找到:To avoid BadTokenException, you need to defer showing the popup until after all the lifecycle methods are called (-> activity window is displayed),简而言之就是要在布局全部加载完之后再去加载PopupWindow,显示PopupWindow过早就会直接crash.
2.在Activity取出string资源文件值,textView.setText(R.string.XXX)是错误的写法应g改为-->textView.setText(getString(R.string.xxx))或者getResources().getString(R.string.xxx),原因:http://stackoverflow.com/questions/11536326/android-settext-r-string-values
描述
(第一句一语道破天机,R.string.xxx仅仅是资源的ID,所以R.String.xxx得到的是资源的编号)

Android PopupWindow实现右侧、左侧和底部弹出菜单

Android PopupWindow实现右侧、左侧和底部弹出菜单

本教程为大家分享了Android PopupWindow弹出菜单的具体代码,供大家参考,具体内容如下

项目代码:http://xiazai.jb51.net/201611/yuanma/PopupLeftMenu(jb51.net).rar

项目SDK是5.1,建议将代码拷到自己的工程中去

代码如下:

MainActivity类:

package com.example.popupleftmenu; 
 
import android.app.Activity; 
import android.content.Context; 
import android.graphics.drawable.ColorDrawable; 
import android.os.Bundle; 
import android.view.Gravity; 
import android.view.MotionEvent; 
import android.view.View; 
import android.view.View.OnClickListener; 
import android.view.View.OnTouchListener; 
import android.view.ViewGroup.LayoutParams; 
import android.view.WindowManager; 
import android.widget.Button; 
import android.widget.PopupWindow; 
import android.widget.Toast; 
 
public class MainActivity extends Activity { 
 
 private Context context = null; 
 private PopupWindow popupWindow; 
 private int from = 0; 
  
 @Override 
 protected void onCreate(Bundle savedInstanceState) { 
  super.onCreate(savedInstanceState); 
  context = this; 
  setContentView(R.layout.activity_main); 
  Button popLeftBtn = (Button)findViewById(R.id.pop_left_btn); 
  Button popRightBtn = (Button)findViewById(R.id.pop_right_btn); 
  Button popBottomBtn = (Button)findViewById(R.id.pop_bottom_btn); 
  popLeftBtn.setonClickListener(popClick); 
  popRightBtn.setonClickListener(popClick); 
  popBottomBtn.setonClickListener(popClick); 
 } 
 
  
 OnClickListener popClick = new OnClickListener() { 
   
  @Override 
  public void onClick(View v) { 
   switch(v.getId()){ 
    case R.id.pop_left_btn:{ 
     from = Location.LEFT.ordinal(); 
     break; 
    } 
    case R.id.pop_right_btn:{ 
     from = Location.RIGHT.ordinal(); 
     break; 
    } 
    case R.id.pop_bottom_btn:{ 
     from = Location.BottOM.ordinal(); 
     break; 
    } 
   } 
    
   //调用此方法,menu不会顶置 
   //popupWindow.showAsDropDown(v); 
   initPopupWindow(); 
    
  } 
 }; 
 /** 
  * 添加新笔记时弹出的popWin关闭的事件,主要是为了将背景透明度改回来 
  * 
  */ 
 class popupdismissListener implements PopupWindow.OndismissListener{ 
 
  @Override 
  public void ondismiss() { 
   backgroundAlpha(1f); 
  } 
   
 } 
  
  
 protected void initPopupWindow(){ 
  View popupWindowView = getLayoutInflater().inflate(R.layout.pop,null); 
  //内容,高度,宽度 
  if(Location.BottOM.ordinal() == from){ 
   popupWindow = new PopupWindow(popupWindowView,LayoutParams.FILL_PARENT,LayoutParams.WRAP_CONTENT,true); 
  }else{ 
   popupWindow = new PopupWindow(popupWindowView,true); 
  } 
  //动画效果 
  if(Location.LEFT.ordinal() == from){ 
   popupWindow.setAnimationStyle(R.style.AnimationLeftFade); 
  }else if(Location.RIGHT.ordinal() == from){ 
   popupWindow.setAnimationStyle(R.style.AnimationRightFade); 
  }else if(Location.BottOM.ordinal() == from){ 
   popupWindow.setAnimationStyle(R.style.AnimationBottomFade); 
  } 
  //菜单背景色 
  ColorDrawable dw = new ColorDrawable(0xffffffff); 
  popupWindow.setBackgroundDrawable(dw); 
  //宽度 
  //popupWindow.setWidth(LayoutParams.WRAP_CONTENT); 
  //高度 
  //popupWindow.setHeight(LayoutParams.FILL_PARENT); 
  //显示位置 
  if(Location.LEFT.ordinal() == from){ 
   popupWindow.showAtLocation(getLayoutInflater().inflate(R.layout.activity_main,null),Gravity.LEFT,500); 
  }else if(Location.RIGHT.ordinal() == from){ 
   popupWindow.showAtLocation(getLayoutInflater().inflate(R.layout.activity_main,Gravity.RIGHT,500); 
  }else if(Location.BottOM.ordinal() == from){ 
   popupWindow.showAtLocation(getLayoutInflater().inflate(R.layout.activity_main,Gravity.BottOM|Gravity.CENTER_HORIZONTAL,0); 
  } 
  //设置背景半透明 
  backgroundAlpha(0.5f); 
  //关闭事件 
  popupWindow.setondismissListener(new popupdismissListener()); 
   
  popupWindowView.setonTouchListener(new OnTouchListener() { 
    
   @Override 
   public boolean onTouch(View v,MotionEvent event) { 
    /*if( popupWindow!=null && popupWindow.isShowing()){ 
     popupWindow.dismiss(); 
     popupWindow=null; 
    }*/ 
    // 这里如果返回true的话,touch事件将被拦截 
    // 拦截后 PopupWindow的onTouchEvent不被调用,这样点击外部区域无法dismiss 
    return false; 
   } 
  }); 
   
  Button open = (Button)popupWindowView.findViewById(R.id.open); 
  Button save = (Button)popupWindowView.findViewById(R.id.save); 
  Button close = (Button)popupWindowView.findViewById(R.id.close); 
   
   
  open.setonClickListener(new OnClickListener() { 
    
   @Override 
   public void onClick(View v) { 
    Toast.makeText(context,"Open",Toast.LENGTH_LONG).show(); 
    popupWindow.dismiss(); 
   } 
  }); 
   
  save.setonClickListener(new OnClickListener() { 
    
   @Override 
   public void onClick(View v) { 
    Toast.makeText(context,Toast.LENGTH_LONG).show(); 
    popupWindow.dismiss(); 
   } 
  }); 
   
  close.setonClickListener(new OnClickListener() { 
    
   @Override 
   public void onClick(View v) { 
    Toast.makeText(context,Toast.LENGTH_LONG).show(); 
    popupWindow.dismiss(); 
   } 
  }); 
 } 
  
 /** 
  * 设置添加屏幕的背景透明度 
  * @param bgalpha 
  */ 
 public void backgroundAlpha(float bgalpha) 
 { 
  WindowManager.LayoutParams lp = getwindow().getAttributes(); 
  lp.alpha = bgalpha; //0.0-1.0 
  getwindow().setAttributes(lp); 
 } 
 /** 
  * 菜单弹出方向 
  * 
  */ 
 public enum Location { 
 
  LEFT,RIGHT,TOP,BottOM; 
   
 } 
} 

两个布局文件:

1.activity_main.xml,就三个Button

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
 xmlns:tools="http://schemas.android.com/tools" 
 android:layout_width="fill_parent" 
 android:layout_height="fill_parent" 
 android:orientation="vertical"> 
 
 <Button 
  android:id="@+id/pop_left_btn" 
  android:layout_width="fill_parent" 
  android:layout_height="wrap_content" 
  android:text="@string/pop_left"/> 
  
 <Button 
  android:id="@+id/pop_right_btn" 
  android:layout_width="fill_parent" 
  android:layout_height="wrap_content" 
  android:text="@string/pop_right"/> 
  
 <Button 
  android:id="@+id/pop_bottom_btn" 
  android:layout_width="fill_parent" 
  android:layout_height="wrap_content" 
  android:text="@string/pop_bottom"/> 
  
 
</LinearLayout>

2. pop.xml,也是三个Button,可以自己修改

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
 android:layout_width="fill_parent" 
 android:layout_height="fill_parent" 
 android:orientation="vertical" > 
  
 <!-- <LinearLayout 
  android:layout_width="wrap_content" 
  android:layout_height="fill_parent" 
  android:orientation="vertical" 
  android:background="#ffffff"> --> 
   
  <Button android:id="@+id/open" 
   android:layout_width="fill_parent" 
   android:layout_height="wrap_content" 
   android:text="@string/open"/> 
   
  <Button android:id="@+id/save" 
   android:layout_width="fill_parent" 
   android:layout_height="wrap_content" 
   android:text="@string/save"/> 
   
  <Button android:id="@+id/close" 
   android:layout_width="fill_parent" 
   android:layout_height="wrap_content" 
   android:text="@string/close"/> 
   
 <!-- </LinearLayout> --> 
  
</LinearLayout> 

strings.xml

<string name="pop_left">弹出左侧菜单</string> 
 <string name="pop_right">弹出右侧菜单</string> 
 <string name="pop_bottom">弹出底部菜单</string> 
 <string name="open">打开</string> 
 <string name="save">保存</string> 
 <string name="close">关闭</string> 

styles.xml

<style name="AnimationLeftFade"> 
  <item name="android:windowEnteranimation">@anim/in_lefttoright</item> 
  <item name="android:windowExitAnimation">@anim/out_righttoleft</item> 
 </style> 
  
 <style name="AnimationRightFade"> 
  <item name="android:windowEnteranimation">@anim/in_righttoleft</item> 
  <item name="android:windowExitAnimation">@anim/out_lefttoright</item> 
 </style> 
  
 <style name="AnimationBottomFade"> 
  <item name="android:windowEnteranimation">@anim/in_bottomtotop</item> 
  <item name="android:windowExitAnimation">@anim/out_toptobottom</item> 
 </style> 

左边弹出菜单动画文件:

in_lefttoright.xml:从左边入

<?xml version="1.0" encoding="utf-8"?> 
<set xmlns:android="http://schemas.android.com/apk/res/android"> 
  
 <translate 
  android:fromXDelta="-100%" 
  android:toXDelta="0" 
  android:duration="500"/> 
  
</set> 

out_righttoleft.xml:从右边出

<?xml version="1.0" encoding="utf-8"?> 
<set xmlns:android="http://schemas.android.com/apk/res/android"> 
  
 <translate android:fromXDelta="0" 
  android:toXDelta="-100%" 
  android:duration="500"/> 
 
</set> 

其他动画文件自己参考写,就是fromXDelta, fromYDelta, toXDelta和toYDelta使用。

以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持编程小技巧。

Android PopupWindow弹不出来(已解决)

Android PopupWindow弹不出来(已解决)

同样的代码,在华为手机中没出现这个问题,但在Vivo X7上,PopupWindow确死活弹不出来,logcat中又没有错误提示。以下是PopupWindow中必须设置的:

setWidth(ViewGroup.LayoutParams.MATCH_PARENT);
setHeight(ViewGroup.LayoutParams.WRAP_CONTENT);
setFocusable(true);
setBackgroundDrawable(new BitmapDrawable());

我是由于没有写setHeight,所以在某些手机上,PopupWindow弹不出来

 

今天关于Android开发实现popupWindow弹出窗口自定义布局与位置控制方法android popwindow在指定位置弹出的分享就到这里,希望大家有所收获,若想了解更多关于android PopupWindow 和 Activity弹出窗口实现方式、Android PopupWindow 实现自定义菜单弹窗效果、Android PopupWindow实现右侧、左侧和底部弹出菜单、Android PopupWindow弹不出来(已解决)等相关知识,可以在本站进行查询。

本文标签:

上一篇Android实现桌面悬浮小火箭效果(android实现桌面悬浮小火箭效果怎么设置)

下一篇Android编程实现使用handler在子线程中更新UI示例(android子线程更新ui的方法)