android popwindow仿微信右上角弹出框,dialog底部显示

新建,弹出popwindow:

/** 弹popwindow **/

tv = (TextView) findViewById(R.id.textView1);

view_pop = LayoutInflater.from(MainActivity.this).inflate(

R.layout.pop_menu, null);

tv.setOnClickListener(new OnClickListener() {

@Override

public void onClick(View arg0) {

if (mPopupwinow == null) {

//新建一个popwindow

mPopupwinow = new PopupWindow(view_pop,

LayoutParams.WRAP_CONTENT,

LayoutParams.WRAP_CONTENT, true);

//设置popwindow的背景颜色

mPopupwinow.setBackgroundDrawable(new ColorDrawable(

0x00000000));

}

//设置popwindow的位置  tv:为微信右上角+号view,居于+号下方

mPopupwinow.showAsDropDown(tv, 0, 0);

}

});

布局pop_menu.xml:

<?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:background=“#00000000”

android:orientation=“vertical” >

<LinearLayout

android:layout_width=“wrap_content”

android:layout_height=“wrap_content”

android:background=“#fff”

android:gravity=“center_vertical”

android:orientation=“vertical” >

<LinearLayout

android:layout_width=“wrap_content”

android:layout_height=“50dp”

android:layout_marginRight=“50dp”

android:gravity=“center_vertical”

android:orientation=“horizontal” >

<ImageView

android:id=“@+id/imageView1”

android:layout_width=“wrap_content”

android:layout_height=“wrap_content”

android:paddingLeft=“20dp”

android:src=“@drawable/ic_launcher” />

<TextView

android:id=“@+id/textView1”

android:layout_width=“wrap_content”

android:layout_height=“wrap_content”

android:layout_marginLeft=“15dp”

android:text=“发起聊天”

android:textSize=“18sp” />

<View

android:layout_width=“match_parent”

android:layout_height=“1dp”

android:background=“#efefef” />

<LinearLayout

android:layout_width=“match_parent”

android:layout_height=“50dp”

android:gravity=“center_vertical”

android:orientation=“horizontal” >

<ImageView

android:id=“@+id/imageView1”

android:layout_width=“wrap_content”

android:layout_height=“wrap_content”

android:paddingLeft=“20dp”

android:src=“@drawable/ic_launcher” />

<TextView

android:id=“@+id/textView1”

android:layout_width=“wrap_content”

android:layout_height=“wrap_content”

android:layout_marginLeft=“15dp”

android:text=“发起聊天”

android:textSize=“18sp” />

<View

android:layout_width=“match_parent”

android:layout_height=“1dp”

android:background=“#efefef” />

<LinearLayout

android:layout_width=“match_parent”

android:layout_height=“50dp”

android:gravity=“center_vertical”

android:orientation=“horizontal” >

<ImageView

android:id=“@+id/imageView1”

android:layout_width=“wrap_content”

android:layout_height=“wrap_content”

android:paddingLeft=“20dp”

android:src=“@drawable/ic_launcher” />

<TextView

android:id=“@+id/textView1”

android:layout_width=“wrap_content”

android:layout_height=“wrap_content”

android:layout_marginLeft=“15dp”

android:text=“发起聊天”

android:textSize=“18sp” />

<View

android:layout_width=“match_parent”

android:layout_height=“1dp”

android:background=“#efefef” />

<LinearLayout

android:layout_width=“match_parent”

android:layout_height=“50dp”

android:gravity=“center_vertical”

android:orientation=“horizontal” >

<ImageView

android:id=“@+id/imageView1”

android:layout_width=“wrap_content”

android:layout_height=“wrap_content”

android:paddingLeft=“20dp”

android:src=“@drawable/ic_launcher” />

<TextView

android:id=“@+id/textView1”

android:layout_width=“wrap_content”

android:layout_height=“wrap_content”

android:layout_marginLeft=“15dp”

android:text=“发起聊天”

android:textSize=“18sp” />

效果:

1、屏幕下方dialog


创建dialog,设置dialog的位置

/** 弹dialog **/

private void showDialog() {

dialog = new Dialog(this,R.style.dialog);

view_dialog = LayoutInflater.from(MainActivity.this).inflate(

R.layout.dialog_layout, null);

dialog.setContentView(view_dialog);

TextView tv_cancle = (TextView) view_dialog

.findViewById(R.id.tv_cancle);

tv_cancle.setOnClickListener(new OnClickListener() {

@Override

public void onClick(View arg0) {

dialog.dismiss();

}

});

/*

  • 获取圣诞框的窗口对象及参数对象以修改对话框的布局设置, 可以直接调用getWindow(),表示获得这个Activity的Window

  • 对象,这样这可以以同样的方式改变这个Activity的属性.

*/

自我介绍一下,小编13年上海交大毕业,曾经在小公司待过,也去过华为、OPPO等大厂,18年进入阿里一直到现在。

深知大多数初中级安卓工程师,想要提升技能,往往是自己摸索成长,但自己不成体系的自学效果低效又漫长,而且极易碰到天花板技术停滞不前!

因此收集整理了一份《2024年最新Android移动开发全套学习资料》送给大家,初衷也很简单,就是希望能够帮助到想自学提升又不知道该从何学起的朋友,同时减轻大家的负担。
img
img
img
img

由于文件比较大,这里只是将部分目录截图出来,每个节点里面都包含大厂面经、学习笔记、源码讲义、实战项目、讲解视频
如果你觉得这些内容对你有帮助,可以添加下面V无偿领取!(备注Android)
img

最后

这里附上上述的技术体系图相关的几十套腾讯、头条、阿里、美团等公司2021年的面试题,把技术点整理成了视频和PDF(实际上比预期多花了不少精力),包含知识脉络 + 诸多细节,由于篇幅有限,这里以图片的形式给大家展示一部分。

相信它会给大家带来很多收获:

img

上述高清技术脑图以及配套的架构技术PDF可以点击我的GitHub免费获取

当程序员容易,当一个优秀的程序员是需要不断学习的,从初级程序员到高级程序员,从初级架构师到资深架构师,或者走向管理,从技术经理到技术总监,每个阶段都需要掌握不同的能力。早早确定自己的职业方向,才能在工作和能力提升中甩开同龄人。

  • 无论你现在水平怎么样一定要 持续学习 没有鸡汤,别人看起来的毫不费力,其实费了很大力,这四个字就是我的建议!!!
  • 我希望每一个努力生活的IT工程师,都会得到自己想要的,因为我们很辛苦,我们应得的。

当我们在抱怨环境,抱怨怀才不遇的时候,没有别的原因,一定是你做的还不够好!

家带来很多收获:**

[外链图片转存中…(img-YxKLN7AQ-1711291234741)]

上述高清技术脑图以及配套的架构技术PDF可以点击我的GitHub免费获取

当程序员容易,当一个优秀的程序员是需要不断学习的,从初级程序员到高级程序员,从初级架构师到资深架构师,或者走向管理,从技术经理到技术总监,每个阶段都需要掌握不同的能力。早早确定自己的职业方向,才能在工作和能力提升中甩开同龄人。

  • 无论你现在水平怎么样一定要 持续学习 没有鸡汤,别人看起来的毫不费力,其实费了很大力,这四个字就是我的建议!!!
  • 我希望每一个努力生活的IT工程师,都会得到自己想要的,因为我们很辛苦,我们应得的。

当我们在抱怨环境,抱怨怀才不遇的时候,没有别的原因,一定是你做的还不够好!

  • 14
    点赞
  • 8
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值