Android实现底部弹出按钮菜单升级版

 更新时间:2017年10月09日 17:19:24   作者:JustingWang_1  
这篇文章主要为大家详细介绍了Android实现底部弹出按钮菜单的升级版,具有一定的参考价值,感兴趣的小伙伴们可以参考一下

本文实例为大家分享了Android实现底部弹出按钮菜单的具体代码,在Android实现底部缓慢弹出菜单的升级,供大家参考,具体内容如下

只贴出关键代码

 case R.id.myself_share:
        //我的分享
        getShareMune();

getShareMune()

private void getShareMune() {

    final Dialog mdialog = new Dialog(getActivity(), R.style.photo_dialog);
    mdialog.setContentView(View.inflate(getActivity(), R.layout.layout_popwindow, null));
    // 弹出对话框
    Window window = mdialog.getWindow();
    WindowManager.LayoutParams lp = window.getAttributes();
    lp.gravity = Gravity.BOTTOM;
    lp.y = 20;
    window.setContentView(R.layout.layout_popwindow);
    final Button qq = (Button) window.findViewById(R.id.btn_QQ);
    final Button sina = (Button) window.findViewById(R.id.btn_sina);
    final Button firend = (Button) window.findViewById(R.id.btn_wechatfirend);
    final Button firend1 = (Button) window.findViewById(R.id.btn_wechatfirend1);
    final Button more = (Button) window.findViewById(R.id.btn_more);
    final Button back = (Button) window.findViewById(R.id.btn_cancel);

    //QQ
    qq.setOnClickListener(new View.OnClickListener() {
      @Override
      public void onClick(View v) {
        showZiDingYi(QQ.NAME);
        mdialog.dismiss();
      }
    });
    //新浪
    sina.setOnClickListener(new View.OnClickListener() {
      @Override
      public void onClick(View v) {
//        showZiDingYi(SinaWeibo.NAME);
        mdialog.dismiss();
      }
    });
    //微信好友
    firend.setOnClickListener(new View.OnClickListener() {
      @Override
      public void onClick(View v) {
        showZiDingYi(Wechat.NAME);
        mdialog.dismiss();
      }
    });
    //微信朋友圈
    firend1.setOnClickListener(new View.OnClickListener() {
      @Override
      public void onClick(View v) {
        showZiDingYi(WechatMoments.NAME);
        mdialog.dismiss();
      }
    });
    //更多
    more.setOnClickListener(new View.OnClickListener() {
      @Override
      public void onClick(View v) {
        mdialog.dismiss();
      }
    });
    //取消
    back.setOnClickListener(new View.OnClickListener() {
      @Override
      public void onClick(View v) {

      }
    });
    mdialog.show();

  }

这里还有个Style

<style name="photo_dialog" parent="android:style/Theme.Dialog">
    <item name="android:windowAnimationStyle">@style/AnimBottom</item>
    <item name="android:windowFrame">@null</item>
    <!-- 边框 -->
    <item name="android:windowIsFloating">true</item>
    <!-- 是否浮现在activity之上 -->
    <item name="android:windowIsTranslucent">true</item>
    <!-- 半透明 -->
    <item name="android:windowNoTitle">true</item>
    <!-- 无标题 -->
    <item name="android:windowBackground">@android:color/transparent</item>
    <!-- 背景透明 -->
    <item name="android:backgroundDimEnabled">true</item>
    <!-- 模糊 -->
  </style>


还有一个XML

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
  android:layout_width="fill_parent"
  android:layout_height="wrap_content"
  android:gravity="center_horizontal"
  android:orientation="vertical">

  <LinearLayout
    android:id="@+id/pop_layout"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:orientation="vertical">

    <Button
      android:id="@+id/btn_QQ"
      android:layout_width="match_parent"
      android:layout_height="wrap_content"
      android:background="@drawable/button_alter_top_radiu"
      android:padding="@dimen/standard_30px"
      android:text="分享到QQ"
      android:textColor="@color/black" />
    <View
      android:layout_width="match_parent"
      android:layout_height="0.5dp"
      android:background="@color/color_dialog_line" />
    <Button
      android:id="@+id/btn_sina"
      android:layout_width="match_parent"
      android:layout_height="wrap_content"
      android:background="@drawable/linearlayout_border_no_radiu"
      android:padding="@dimen/standard_30px"
      android:text="分享到新浪"
      android:textColor="@color/black" />
    <View
      android:layout_width="match_parent"
      android:layout_height="0.5dp"
      android:background="@color/color_dialog_line" />
    <Button
      android:id="@+id/btn_wechatfirend"
      android:layout_width="match_parent"
      android:layout_height="wrap_content"
      android:background="@drawable/linearlayout_border_no_radiu"
      android:padding="@dimen/standard_30px"
      android:text="分享到微信好友"
      android:textColor="@color/black" />
    <View
      android:layout_width="match_parent"
      android:layout_height="0.5dp"
      android:background="@color/color_dialog_line" />
    <Button
      android:id="@+id/btn_wechatfirend1"
      android:layout_width="match_parent"
      android:layout_height="wrap_content"
      android:background="@drawable/linearlayout_border_no_radiu"
      android:padding="@dimen/standard_30px"
      android:text="分享到微信朋友圈"
      android:textColor="@color/black" />
    <View
      android:layout_width="match_parent"
      android:layout_height="0.5dp"
      android:background="@color/color_dialog_line" />

    <Button
      android:id="@+id/btn_more"
      android:layout_width="match_parent"
      android:layout_height="wrap_content"
      android:background="@drawable/button_alter_bottom_radiu"
      android:padding="@dimen/standard_30px"
      android:text="分享到更多..."
      android:textColor="@color/black" />

    <Button
      android:layout_marginTop="@dimen/standard_20px"
      android:id="@+id/btn_cancel"
      android:layout_width="match_parent"
      android:layout_height="wrap_content"
      android:background="@drawable/button_radius_white_lemonchiffon"
      android:padding="@dimen/standard_30px"
      android:text="取消"
      android:textColor="@color/black" />
  </LinearLayout>
</RelativeLayout>

上效果图

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

相关文章

  • Android编程之简单计时器实现方法

    Android编程之简单计时器实现方法

    这篇文章主要介绍了Android编程之简单计时器实现方法,涉及Android开发中ContextMenu及Chronometer的相关使用技巧,需要的朋友可以参考下
    2016-01-01
  • Android仿微信、qq点击右上角加号弹出操作框

    Android仿微信、qq点击右上角加号弹出操作框

    这篇文章主要为大家详细介绍了Android仿微信、qq点击右上角加号弹出操作框,具有一定的参考价值,感兴趣的小伙伴们可以参考一下
    2018-04-04
  • Android编程设计模式之抽象工厂模式详解

    Android编程设计模式之抽象工厂模式详解

    这篇文章主要介绍了Android编程设计模式之抽象工厂模式,结合实例形式详细分析了Android抽象工厂模式的概念、原理、使用方法及相关注意事项,需要的朋友可以参考下
    2017-12-12
  • ANDROID BottomNavigationBar底部导航栏的实现示例

    ANDROID BottomNavigationBar底部导航栏的实现示例

    本篇文章主要介绍了ANDROID BottomNavigationBar底部导航栏的实现示例,非常具有实用价值,需要的朋友可以参考下
    2017-10-10
  • 简单实现Android计算器功能

    简单实现Android计算器功能

    这篇文章主要为大家详细介绍了自己动手实现的Android计算器功能,具有一定的参考价值,感兴趣的小伙伴们可以参考一下
    2017-01-01
  • Android 开源项目侧边栏菜单(SlidingMenu)使用详解

    Android 开源项目侧边栏菜单(SlidingMenu)使用详解

    SlidingMenu的是一种比较新的设置界面或配置界面效果,在主界面左滑或者右滑出现设置界面,能方便的进行各种操作.目前有大量的应用都在使用这一效果。如Evernote、Google+、Foursquare等,国内的豌豆夹,人人,360手机助手等都使用SlidingMenu的界面方案。
    2016-05-05
  • Android实现系统日历同步日程

    Android实现系统日历同步日程

    这篇文章主要为大家详细介绍了Android实现系统日历同步日程,文中示例代码介绍的非常详细,具有一定的参考价值,感兴趣的小伙伴们可以参考一下
    2021-04-04
  • Android利用zxing快速集成二维码扫描的实例教程

    Android利用zxing快速集成二维码扫描的实例教程

    最近二维码真是越来越火了,随便电视上、网络上、商场里,到处都是二维码,所以下面这篇文章我们就来给大家介绍关于Android利用zxing快速集成二维码扫描的相关资料,需要的朋友可以参考借鉴,下面随着小编来一起看看吧。
    2017-09-09
  • Android的进度条控件描述

    Android的进度条控件描述

    这篇文章主要介绍了android的几种进度条控件描述的相关资料,非常不错,具有参考借鉴价值,需要的朋友可以参考下
    2017-01-01
  • Android自定义view实现拖动小球移动

    Android自定义view实现拖动小球移动

    这篇文章主要为大家详细介绍了Android自定义view实现拖动小球移动,文中示例代码介绍的非常详细,具有一定的参考价值,感兴趣的小伙伴们可以参考一下
    2020-11-11

最新评论