电脑知识|欧美黑人一区二区三区|软件|欧美黑人一级爽快片淫片高清|系统|欧美黑人狂野猛交老妇|数据库|服务器|编程开发|网络运营|知识问答|技术教程文章 - 好吧啦网

您的位置:首頁技術(shù)文章
文章詳情頁

Android仿新浪微博發(fā)送菜單界面的實(shí)現(xiàn)

瀏覽:168日期:2022-06-05 18:52:11
效果圖

Android仿新浪微博發(fā)送菜單界面的實(shí)現(xiàn)

接下來就是一波貼代碼的過程

自定義Dialog

public class SinaSendView extends Dialog { private ImageButton ib_dialog_sina_close; private LinearLayout ll_dialog_sina_write; private LinearLayout ll_dialog_sina_time; private LinearLayout ll_dialog_sina_map; private LinearLayout ll_dialog_sina_menu; private ImageView iv_dialog_sina_bg,iv_dialog_sina_des; private Context mContext; private Boolean hideDes; private Bitmap screenShot; private Bitmap bitmap; private ByteArrayOutputStream baos; private byte[] bytes; public SinaSendView(Context context) { super(context); this.mContext = context; } public SinaSendView(Context context, int themeResId,Boolean hideDes) { super(context, themeResId); this.mContext = context; this.hideDes = hideDes; } protected SinaSendView(Context context, boolean cancelable, OnCancelListener cancelListener) { super(context, cancelable, cancelListener); this.mContext = context; } @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); this.setContentView(R.layout.layout_sina_send_dialog); ib_dialog_sina_close = (ImageButton) findViewById(R.id.ib_dialog_sina_close); ll_dialog_sina_write = (LinearLayout) findViewById(R.id.ll_dialog_sina_write); ll_dialog_sina_time = (LinearLayout) findViewById(R.id.ll_dialog_sina_time); ll_dialog_sina_map = (LinearLayout) findViewById(R.id.ll_dialog_sina_map); ll_dialog_sina_menu = (LinearLayout) findViewById(R.id.ll_dialog_sina_menu); iv_dialog_sina_bg = (ImageView) findViewById(R.id.iv_dialog_sina_bg); iv_dialog_sina_des = (ImageView) findViewById(R.id.iv_dialog_sina_des); initView(); } private void initView() { setBrulBg(); ll_dialog_sina_menu.setVisibility(View.VISIBLE); ll_dialog_sina_menu.setAnimation(AnimationUtil.moveToViewLocationFromTop()); ib_dialog_sina_close.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) {ll_dialog_sina_menu.setAnimation(AnimationUtil.moveToViewBottom());ll_dialog_sina_menu.setVisibility(View.GONE);dismiss(); } }); if(hideDes){ iv_dialog_sina_des.setVisibility(View.GONE); } } /** * 設(shè)置模糊背景 */ private void setBrulBg(){ screenShot = CommonUtils.getInstance().getScreenShot((Activity) mContext); bitmap = CommonUtils.getInstance().zoomImg(screenShot, 0.2f); baos = new ByteArrayOutputStream(); bitmap.compress(Bitmap.CompressFormat.JPEG, 1, baos); bytes = baos.toByteArray(); Glide.with(mContext).load(bytes).asBitmap().transform(new BlurTransformation(CommonUtils.getInstance().getContext(), 25)).into(iv_dialog_sina_bg); } public void setClick(final SinaSendDialog mSinaSendDialog){ this.show(); ll_dialog_sina_write.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) {mSinaSendDialog.onNormalClick();dismiss(); } }); ll_dialog_sina_map.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) {mSinaSendDialog.onMapClick();dismiss(); } }); ll_dialog_sina_time.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) {mSinaSendDialog.onTimeClick();dismiss(); } }); } @Override public void dismiss() { super.dismiss(); if(screenShot != null && !screenShot.isRecycled()){ screenShot.recycle(); screenShot = null; } if(bitmap != null && !bitmap.isRecycled()){ bitmap.recycle(); bitmap = null; } try { baos.close(); } catch (IOException e) { e.printStackTrace(); } bytes = null; System.gc(); }}布局文件

<?xml version='1.0' encoding='utf-8'?><FrameLayout xmlns:android='http://schemas.android.com/apk/res/android' android:layout_width='match_parent' android:layout_height='match_parent' > <ImageView android: android:layout_width='match_parent' android:layout_height='match_parent' android:scaleType='fitXY' /> <ImageButton android: android:layout_width='15dp' android:layout_height='15dp' android:src='http://www.hdgsjgj.cn/bcjs/@drawable/dialog_sina_send_close' android:background='@null' android:layout_gravity='bottom|center_horizontal' android:layout_marginBottom='17dp' /> <ImageView android:layout_width='match_parent' android:layout_height='0.5dp' android:background='@color/line_gray' android:layout_gravity='bottom' android:layout_marginBottom='50dp' /> <LinearLayout android: android:layout_width='wrap_content' android:layout_height='wrap_content' android:layout_gravity='bottom|center_horizontal' android:layout_marginBottom='120dp' android:orientation='horizontal' android:visibility='gone' > <LinearLayout android: android:layout_width='wrap_content' android:layout_height='wrap_content' android:orientation='vertical' android:gravity='center_horizontal' > <ImageViewandroid:layout_width='75dp'android:layout_height='75dp'android:src='http://www.hdgsjgj.cn/bcjs/@drawable/dialog_sina_send_write'/> <TextViewandroid:layout_width='wrap_content'android:layout_height='wrap_content'android:textSize='13sp'android:textColor='@color/text_gray'android:text='一般內(nèi)容'android:layout_marginTop='8dp'/> </LinearLayout> <LinearLayout android: android:layout_width='wrap_content' android:layout_height='wrap_content' android:orientation='vertical' android:gravity='center_horizontal' android:layout_marginLeft='35dp' android:layout_marginRight='35dp' > <ImageViewandroid:layout_width='75dp'android:layout_height='75dp'android:src='http://www.hdgsjgj.cn/bcjs/@drawable/dialog_sina_send_time'/> <TextViewandroid:layout_width='wrap_content'android:layout_height='wrap_content'android:textSize='13sp'android:textColor='@color/text_gray'android:text='時(shí)間膠囊'android:layout_marginTop='8dp'/> </LinearLayout> <LinearLayout android: android:layout_width='wrap_content' android:layout_height='wrap_content' android:orientation='vertical' android:gravity='center_horizontal' > <ImageViewandroid:layout_width='75dp'android:layout_height='75dp'android:src='http://www.hdgsjgj.cn/bcjs/@drawable/dialog_sina_send_map'/> <TextViewandroid:layout_width='wrap_content'android:layout_height='wrap_content'android:textSize='13sp'android:textColor='@color/text_gray'android:text='地點(diǎn)膠囊'android:layout_marginTop='8dp'/> </LinearLayout> </LinearLayout> <ImageView android: android:layout_width='wrap_content' android:layout_height='wrap_content' android:src='http://www.hdgsjgj.cn/bcjs/@drawable/dialog_sina_send_des' android:layout_gravity='center_horizontal' android:layout_marginTop='70dp' /></FrameLayout>Style

<style name='SinaSendDialog'> <item name='android:windowFullscreen'>true</item> <item name='android:windowNoTitle'>true</item> <item name='android:windowBackground'>@android:color/transparent</item></style>工具方法

/** * 從控件的頂部移動(dòng)到控件所在位置 * * @return */ public static TranslateAnimation moveToViewLocationFromTop() { TranslateAnimation mHiddenAction = new TranslateAnimation(Animation.RELATIVE_TO_SELF, 0.0f,Animation.RELATIVE_TO_SELF, 0.0f, Animation.RELATIVE_TO_SELF,-1.0f, Animation.RELATIVE_TO_SELF, 0.0f); mHiddenAction.setDuration(500); return mHiddenAction; } /** * 截取當(dāng)前屏幕 * @param activity * @return */ public Bitmap getScreenShot(Activity activity) { // 獲取windows中最頂層的view View view = activity.getWindow().getDecorView(); view.buildDrawingCache(); // 獲取狀態(tài)欄高度 Rect rect = new Rect(); view.getWindowVisibleDisplayFrame(rect); int statusBarHeights = rect.top; Display display = activity.getWindowManager().getDefaultDisplay(); // 獲取屏幕寬和高 int widths = display.getWidth(); int heights = display.getHeight(); // 允許當(dāng)前窗口保存緩存信息 view.setDrawingCacheEnabled(true); // 去掉狀態(tài)欄 Bitmap bmp = Bitmap.createBitmap(view.getDrawingCache(), 0,0, widths, heights); // 銷毀緩存信息 view.destroyDrawingCache(); return bmp; } /** * 改變bitmap寬高 * @param bm * @param f * @return */ public Bitmap zoomImg(Bitmap bm,float f){ int width = bm.getWidth(); int height = bm.getHeight(); float scaleWidth = f; float scaleHeight = f; Matrix matrix = new Matrix(); matrix.postScale(scaleWidth, scaleHeight); Bitmap newbm = Bitmap.createBitmap(bm, 0, 0, width, height, matrix, true); return newbm; }接口

public interface SinaSendDialog { void onNormalClick(); void onTimeClick(); void onMapClick();}

基本講一下邏輯,背景采用截屏高斯模糊處理,這里一定要降圖片質(zhì)量,不然會(huì)慢,按鈕采用一個(gè)動(dòng)畫從上向下劃出,雖然不是特別完美,但是多少有個(gè)樣子。

源碼地址:

https://github.com/bertsir/SinaSendView

到這里就結(jié)束啦.

以上就是Android仿新浪微博發(fā)送菜單界面的實(shí)現(xiàn)的詳細(xì)內(nèi)容,更多關(guān)于Android 發(fā)送菜單界面的實(shí)現(xiàn)的資料請(qǐng)關(guān)注好吧啦網(wǎng)其它相關(guān)文章!

標(biāo)簽: 微博
相關(guān)文章:
主站蜘蛛池模板: 桁架机器人_桁架机械手_上下料机械手_数控车床机械手-苏州清智科技装备制造有限公司 | SMC-ASCO-CKD气缸-FESTO-MAC电磁阀-上海天筹自动化设备官网 | 并网柜,汇流箱,电控设备,中高低压开关柜,电气电力成套设备,PLC控制设备订制厂家,江苏昌伟业新能源科技有限公司 | 并网柜,汇流箱,电控设备,中高低压开关柜,电气电力成套设备,PLC控制设备订制厂家,江苏昌伟业新能源科技有限公司 | 周易算网-八字测算网 - 周易算网-宝宝起名取名测名字周易八字测算网 | 嘉兴泰东园林景观工程有限公司_花箱护栏 | 无锡装修装潢公司,口碑好的装饰装修公司-无锡索美装饰设计工程有限公司 | 数码听觉统合训练系统-儿童感觉-早期言语评估与训练系统-北京鑫泰盛世科技发展有限公司 | 武汉刮刮奖_刮刮卡印刷厂_为企业提供门票印刷_武汉合格证印刷_现金劵代金券印刷制作 - 武汉泽雅印刷有限公司 | 爆破器材运输车|烟花爆竹运输车|1-9类危险品厢式运输车|湖北江南专用特种汽车有限公司 | 防爆正压柜厂家_防爆配电箱_防爆控制箱_防爆空调_-盛通防爆 | 收录网| 医疗仪器模块 健康一体机 多参数监护仪 智慧医疗仪器方案定制 血氧监护 心电监护 -朗锐慧康 | 除甲醛公司-甲醛检测治理-杭州创绿家环保科技有限公司-室内空气净化十大品牌 | 成都LED显示屏丨室内户外全彩led屏厂家方案报价_四川诺显科技 | 压力控制器,差压控制器,温度控制器,防爆压力控制器,防爆温度控制器,防爆差压控制器-常州天利智能控制股份有限公司 | 游泳池设备安装工程_恒温泳池设备_儿童游泳池设备厂家_游泳池水处理设备-东莞市君达泳池设备有限公司 | 超声波焊接机_超音波熔接机_超声波塑焊机十大品牌_塑料超声波焊接设备厂家 | 全自动实验室洗瓶机,移液管|培养皿|进样瓶清洗机,清洗剂-广州摩特伟希尔机械设备有限责任公司 | 背压阀|减压器|不锈钢减压器|减压阀|卫生级背压阀|单向阀|背压阀厂家-上海沃原自控阀门有限公司 本安接线盒-本安电路用接线盒-本安分线盒-矿用电话接线盒-JHH生产厂家-宁波龙亿电子科技有限公司 | 世界箱包品牌十大排名,女包小众轻奢品牌推荐200元左右,男包十大奢侈品牌排行榜双肩,学生拉杆箱什么品牌好质量好 - Gouwu3.com | 法兰螺母 - 不锈钢螺母制造厂家 - 万千紧固件--螺母街 | 浙江寺庙设计-杭州寺院设计-宁波寺庙规划_汉匠 | 高防护蠕动泵-多通道灌装系统-高防护蠕动泵-www.bjhuiyufluid.com慧宇伟业(北京)流体设备有限公司 | 卫生纸复卷机|抽纸机|卫生纸加工设备|做卫生纸机器|小型卫生纸加工需要什么设备|卫生纸机器设备多少钱一台|许昌恒源纸品机械有限公司 | PTFE接头|聚四氟乙烯螺丝|阀门|薄膜|消解罐|聚四氟乙烯球-嘉兴市方圆氟塑制品有限公司 | 杭州标识标牌|文化墙|展厅|导视|户内外广告|发光字|灯箱|铭阳制作公司 - 杭州标识标牌|文化墙|展厅|导视|户内外广告|发光字|灯箱|铭阳制作公司 | 房车价格_依维柯/大通/东风御风/福特全顺/江铃图片_云梯搬家车厂家-程力专用汽车股份有限公司 | 广州活动策划公司-15+年专业大型公关活动策划执行管理经验-睿阳广告 | 派财经_聚焦数字经济内容服务平台 | 电子元器件呆滞料_元器件临期库存清仓尾料_尾料优选现货采购处理交易商城 | 二手Sciex液质联用仪-岛津气质联用仪-二手安捷伦气质联用仪-上海隐智科学仪器有限公司 | 橡胶接头|可曲挠橡胶接头|橡胶软接头安装使用教程-上海松夏官方网站 | 布袋除尘器|除尘器设备|除尘布袋|除尘设备_诺和环保设备 | 安全阀_弹簧式安全阀_美标安全阀_工业冷冻安全阀厂家-中国·阿司米阀门有限公司 | 广西教师资格网-广西教师资格证考试网 | 深圳市宏康仪器科技有限公司-模拟高空低压试验箱-高温防爆试验箱-温控短路试验箱【官网】 | 三佳互联一站式网站建设服务|网站开发|网站设计|网站搭建服务商 赛默飞Thermo veritiproPCR仪|ProFlex3 x 32PCR系统|Countess3细胞计数仪|371|3111二氧化碳培养箱|Mirco17R|Mirco21R离心机|仟诺生物 | 集装箱标准养护室-集装箱移动式养护室-广州璟业试验仪器有限公司 | 广州昊至泉水上乐园设备有限公司 | 胀套-锁紧盘-风电锁紧盘-蛇形联轴器「厂家」-瑞安市宝德隆机械配件有限公司 |