效果图:

item_add.xml

<?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:background="#D1D1D1"
android:orientation="vertical" >
<Button
android:id="@+id/album"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="从相册中选取图片"
android:gravity="center"
android:textColor="#595959"
android:textSize="15sp"
android:background="@drawable/kuang_grey_white"
android:layout_marginLeft="15dp"
android:layout_marginRight="15dp"
android:layout_marginTop="10dp"
/>
<Button
android:id="@+id/camera"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="拍照选取图片"
android:gravity="center"
android:textSize="15sp"
android:textColor="#595959"
android:background="@drawable/kuang_grey_white"
android:layout_marginLeft="15dp"
android:layout_marginRight="15dp"
android:layout_marginTop="5dp"
/>
<Button
android:id="@+id/cancel"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="取消"
android:textSize="15sp"
android:gravity="center"
android:textColor="#595959"
android:background="@drawable/kuang_grey_white"
android:layout_marginLeft="15dp"
android:layout_marginRight="15dp"
android:layout_marginTop="5dp"
/>
<View
android:layout_width="match_parent"
android:layout_height="10dp"
android:background="#D1D1D1"
/>
</LinearLayout>

kuang_grey_white.xml

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" >
<stroke android:width="1px" android:color="@color/view" />
<solid android:color="@color/white" />填充色
<corners android:radius="8dp" /> </shape>

方法:

    public void showpopupwindow() {
LayoutInflater inflater = LayoutInflater.from(PersonalInfoActivity.this);
View v = inflater.inflate(R.layout.item_add, null);
Button album = (Button) v.findViewById(R.id.album);
Button camera = (Button) v.findViewById(R.id.camera);
Button cancel = (Button) v.findViewById(R.id.cancel);
album.setOnClickListener(new OnClickListener() { @Override
public void onClick(View v) {
// TODO Auto-generated method stub
// 相册选择图片
//setalbumImg();
}
});
camera.setOnClickListener(new OnClickListener() { @Override
public void onClick(View v) {
// TODO Auto-generated method stub
// setcameraImg(type2);
}
});
cancel.setOnClickListener(new OnClickListener() { @Override
public void onClick(View v) {
// TODO Auto-generated method stub
pw.dismiss();
}
});
// 一般来说,我们在onCreate里面得到的控件的宽高全是0.采用下面的方法,可以得到真实的宽高
int w = View.MeasureSpec.makeMeasureSpec(0,
View.MeasureSpec.UNSPECIFIED);
int h = View.MeasureSpec.makeMeasureSpec(0,
View.MeasureSpec.UNSPECIFIED);
v.measure(w, h);
int v_h = v.getMeasuredHeight();
int v_w = v.getMeasuredWidth(); pw = new PopupWindow(v, LayoutParams.MATCH_PARENT, v_h);
pw.setFocusable(true);
}

使用:

private PopupWindow pw;

showpopupwindow();
pw.showAtLocation(findViewById(R.id.m), Gravity.BOTTOM, 0, 0);//m是整个当前的根布局id

仿QQ的底部选项的更多相关文章

  1. Android高仿qq及微信底部菜单的几种实现方式

    最近项目没那么忙,想着开发app的话,有很多都是重复,既然是重复的,那就没有必要每次都去写,所以就想着写一个app通用的基本框架,这里说的框架不是什么MVC,MVP,MVVM这种,而是app开发的通用 ...

  2. Fragment,仿QQ空间

    转载请注明出处:http://blog.csdn.net/yangyu20121224/article/details/9023451          在今天的这篇文章当中,我依然会以实战加理论结合 ...

  3. android-改进&lt;&lt;仿QQ&gt;&gt;框架源代码

    该文章主要改动于CSDN某大神的一篇文章,本人认为这篇文章的面向对象非常透彻,以下分享例如以下可学习的几点: Android应用经典主界面框架之中的一个:仿QQ (使用Fragment, 附源代码) ...

  4. jQuery实现的3个基础案例(仿QQ列表分组,二级联动下拉框,模拟员工信息管理系统)

    1.仿QQ列表分组 <!DOCTYPE HTML> <html> <head> <meta http-equiv="Content-Type&quo ...

  5. android开发学习 ------- 仿QQ侧滑效果的实现

    需要做一个仿QQ侧滑删除的一个效果: 一开始是毫无头绪,百度找思路,找到  https://blog.csdn.net/xiaxiazaizai01/article/details/53036994  ...

  6. 循序渐进实现仿QQ界面(一):园角矩形与双缓冲贴图窗口

    印象里仿QQ界面的程序应该有很多,搜了一下,虽然出来一大堆,排除了重复的,却只有两三个,没我想象的好.经常看到CSDN上有人问,QQ这个功能怎么实现,那个界面怎么实现,归纳了一下,决定写这么一个仿QQ ...

  7. 循序渐进实现仿QQ界面(三):界面调色与控件自绘

    本篇讲述如何进行界面调色.界面调色一般有两种方法,调色板和HSL色彩变换.调色板局限于256色,这里不采用,因此用HSL色彩变换实现.首先要了解一下什么是HSL色彩空间,完整且详尽的知识请到维基百科去 ...

  8. iOS天气动画、高仿QQ菜单、放京东APP、高仿微信、推送消息等源码

    iOS精选源码 TYCyclePagerView iOS上的一个无限循环轮播图组件 iOS高仿微信完整项目源码 想要更简单的推送消息,看本文就对了 ScrollView嵌套ScrolloView解决方 ...

  9. SignalR快速入门 ~ 仿QQ即时聊天,消息推送,单聊,群聊,多群公聊(基础=》提升)

     SignalR快速入门 ~ 仿QQ即时聊天,消息推送,单聊,群聊,多群公聊(基础=>提升,5个Demo贯彻全篇,感兴趣的玩才是真的学) 官方demo:http://www.asp.net/si ...

随机推荐

  1. VS2015 使用Razor编写MVC视图时,Razor智能提示消失,报各种红线解决方案。

    打开文件夹 Users\<CurrentUser>\AppData\Local\Microsoft\VisualStudio\<version> 删除文件夹 Component ...

  2. HTML5服务器推送消息的各种解决办法

    摘要 在各种BS架构的应用程序中,往往都希望服务端能够主动地向客户端推送各种消息,以达到类似于邮件.消息.待办事项等通知. 往BS架构本身存在的问题就是,服务器一直采用的是一问一答的机制.这就意味着如 ...

  3. 从jQuery源码阅读看 dom load

    最近两天不忙的时候再回过来研究一下jquery的源码,看到$(document).ready()时,深入的研究了一下dom的加载问题. 我们都知道,window.onload可以解决我们的js执行时机 ...

  4. Capture Current Soft Screen

    Bitmap memoryImage; private void CaptureScreen() { Graphics myGraphics = this.CreateGraphics(); Size ...

  5. AX7: Overlayering and extensions

    Customization: Overlayering and extensions https://ax.help.dynamics.com/en/wiki/customization-overla ...

  6. Hibernate注解使用以及Spring整合

    Hibernate注解使用以及Spring整合 原文转自:http://wanqiufeng.blog.51cto.com/409430/484739 (1) 简介: 在过去几年里,Hibernate ...

  7. stimulsoft Report报表使用笔记

    1.使用设计器设计mrt报表模板,或者从其他文件复制修改 2.删除business object 数据源 3.使用代码添加数据源 ParcelChangeItem change = new Parce ...

  8. PHP中获取当前页面的完整URL

    //获取域名或主机地址 echo $_SERVER['HTTP_HOST']."<br>"; #localhost//获取网页地址 echo $_SERVER['PHP ...

  9. FlASK中的endpoint问题

    先贴一点有关的flask代码,时间有限,我慢慢扩充 以下是flask源码中app.py中add_url_rule的代码. 主要是view_func  -- endpoint -- url 之间的对应关 ...

  10. SQL语言基础

    主要学习链接1 http://www.cnblogs.com/anding/p/5281558.html 搜索学习链接2 http://www.cnblogs.com/libingql/p/41342 ...