Android實(shí)現(xiàn)底部彈出按鈕菜單升級(jí)版
本文實(shí)例為大家分享了Android實(shí)現(xiàn)底部彈出按鈕菜單的具體代碼,在Android實(shí)現(xiàn)底部緩慢彈出菜單的升級(jí),供大家參考,具體內(nèi)容如下
只貼出關(guān)鍵代碼
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)); // 彈出對(duì)話框 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(); }
這里還有個(gè)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> <!-- 是否浮現(xiàn)在activity之上 --> <item name="android:windowIsTranslucent">true</item> <!-- 半透明 --> <item name="android:windowNoTitle">true</item> <!-- 無(wú)標(biāo)題 --> <item name="android:windowBackground">@android:color/transparent</item> <!-- 背景透明 --> <item name="android:backgroundDimEnabled">true</item> <!-- 模糊 --> </style>
還有一個(gè)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>
上效果圖
以上就是本文的全部?jī)?nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。
相關(guān)文章
android canvas drawText()文字居中效果
這篇文章主要為大家詳細(xì)介紹了android canvas drawText()文字居中效果,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2017-12-12Android上實(shí)現(xiàn)easyconfig(airkiss)方法
本篇文章主要給大家講解了在Android系統(tǒng)上實(shí)現(xiàn)easyconfig(airkiss)的方法,有這方面需要的朋友參考學(xué)習(xí)下吧。2018-01-01android listview進(jìn)階實(shí)例分享
這篇文章主要介紹了android listview進(jìn)階實(shí)例分享,具有一定借鑒價(jià)值,需要的朋友可以參考下2018-01-01Android編程簡(jiǎn)單設(shè)置ListView分割線的方法
這篇文章主要介紹了Android編程簡(jiǎn)單設(shè)置ListView分割線的方法,涉及Android布局簡(jiǎn)單操作技巧,具有一定參考借鑒價(jià)值,需要的朋友可以參考下2017-02-02Android使用ViewPager快速切換Fragment時(shí)卡頓的優(yōu)化方案
今天小編就為大家分享一篇關(guān)于Android使用ViewPager快速切換Fragment時(shí)卡頓的優(yōu)化方案,小編覺(jué)得內(nèi)容挺不錯(cuò)的,現(xiàn)在分享給大家,具有很好的參考價(jià)值,需要的朋友一起跟隨小編來(lái)看看吧2018-12-12多面分析HarmonyOS與Android的特點(diǎn)
請(qǐng)教身邊的大佬們,公司的CTO、中臺(tái)部門(mén)的總監(jiān)、老東家數(shù)十年行業(yè)經(jīng)驗(yàn)的老架構(gòu)、以及在中科院讀研究生的大學(xué)老室友、技術(shù)圈的網(wǎng)友等等,他們都給出了自己獨(dú)特的看法,讓我從多方面更好的去了解到了大家對(duì)鴻蒙的認(rèn)識(shí)2021-08-08Android開(kāi)發(fā)中避免應(yīng)用無(wú)響應(yīng)的方法(Application Not Responding、ANR)
這篇文章主要介紹了Android開(kāi)發(fā)中避免應(yīng)用無(wú)響應(yīng)的方法,即避免彈出Application Not Responding(ANR)對(duì)話框,需要的朋友可以參考下2014-06-06