Android实现底部弹出按钮菜单 Android实现底部弹出按钮菜单升级版
JustingWang_1 人气:0想了解Android实现底部弹出按钮菜单升级版的相关内容吗,JustingWang_1在本文为您仔细讲解Android实现底部弹出按钮菜单的相关知识和一些Code实例,欢迎阅读和指正,我们先划重点: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>
上效果图
加载全部内容