广告
返回顶部
首页 > 资讯 > 移动开发 >Android 实现抖音头像底部弹框效果的实例代码
  • 769
分享到

Android 实现抖音头像底部弹框效果的实例代码

抖音Android 2022-06-06 15:06:17 769人浏览 安东尼
摘要

布局文件 activity_test.xml <?xml version="1.0" encoding="utf-8"?> <Andro

布局文件

activity_test.xml


<?xml version="1.0" encoding="utf-8"?>
<Androidx.constraintlayout.widget.ConstraintLayout xmlns:android="Http://schemas.android.com/apk/res/android"
  android:layout_width="match_parent"
  android:layout_height="match_parent"
  xmlns:app="http://schemas.android.com/apk/res-auto">
  <LinearLayout
    android:id="@+id/linearLayout"
    android:orientation="vertical"
    app:layout_constraintStart_toStartOf="parent"
    app:layout_constraintBottom_toBottomOf="parent"
    android:background="@color/colorAccent"
    android:layout_width="match_parent"
    android:layout_height="300dp">
  </LinearLayout>
  <View
    android:layout_width="match_parent"
    android:layout_height="100dp"
    app:layout_constraintTop_toTopOf="@+id/linearLayout"
    app:layout_constraintBottom_toTopOf="@+id/linearLayout"
    app:layout_constraintStart_toStartOf="parent"
    app:layout_constraintEnd_toEndOf="parent"
    android:alpha="0"
    android:background="@android:color/white"
    />
  <ImageView
    android:id="@+id/image"
    android:src="@mipmap/ic_launcher"
    app:layout_constraintTop_toTopOf="@+id/linearLayout"
    app:layout_constraintBottom_toTopOf="@+id/linearLayout"
    app:layout_constraintStart_toStartOf="parent"
    app:layout_constraintEnd_toEndOf="parent"
    android:layout_marginTop="100dp"
    android:layout_width="100dp"
    android:layout_height="100dp"/>
</androidx.constraintlayout.widget.ConstraintLayout>

MainActivity.java

点击事件


View contentView = LayoutInflater.from(MainActivity.this).inflate(R.layout.activity_test, null);
        PopupWindow popWnd = new PopupWindow(MainActivity.this);
        popWnd.setContentView(contentView);
        popWnd.setWidth(ViewGroup.LayoutParams.MATCH_PARENT);
        popWnd.setHeight(ViewGroup.LayoutParams.WRAP_CONTENT);
        popWnd.setBackgroundDrawable(new ColorDrawable(0x00000000));
        popWnd.setOutsideTouchable(false);
        popWnd.setFocusable(true);
        //相对于父控件的底部显示 无任何偏移
        popWnd.showAtLocation(v, Gravity.BOTTOM, 0, 0);

在这里插入图片描述

到此这篇关于Android 实现抖音头像底部弹框效果的文章就介绍到这了,更多相关android 抖音弹框内容请搜索编程网以前的文章或继续浏览下面的相关文章希望大家以后多多支持编程网!

您可能感兴趣的文章:Android中 TeaScreenPopupWindow多类型筛选弹框功能的实例代码android自定义Dialog弹框和背景阴影显示效果Android 提交或者上传数据时的dialog弹框动画效果Android简单实现自定义弹框(PopupWindow)浅析Android中常见三种弹框在项目中的应用Android填坑系列:在小米系列等机型上放开定位权限后的定位请求弹框示例


--结束END--

本文标题: Android 实现抖音头像底部弹框效果的实例代码

本文链接: https://www.lsjlt.com/news/29875.html(转载时请注明来源链接)

有问题或投稿请发送至: 邮箱/279061341@qq.com    QQ/279061341

本篇文章演示代码以及资料文档资料下载

下载Word文档到电脑,方便收藏和打印~

下载Word文档
猜你喜欢
软考高级职称资格查询
编程网,编程工程师的家园,是目前国内优秀的开源技术社区之一,形成了由开源软件库、代码分享、资讯、协作翻译、讨论区和博客等几大频道内容,为IT开发者提供了一个发现、使用、并交流开源技术的平台。
  • 官方手机版

  • 微信公众号

  • 商务合作