iis服务器助手广告广告
返回顶部
首页 > 资讯 > 移动开发 >Android仿新浪微博发送菜单界面的实现
  • 593
分享到

Android仿新浪微博发送菜单界面的实现

2024-04-02 19:04:59 593人浏览 八月长安
摘要

目录效果图自定义Dialog布局文件Style工具方法接口效果图 接下来就是一波贴代码的过程 自定义Dialog public class SinaSendView exten

效果图

接下来就是一波贴代码的过程

自定义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);
    }
  }

  
  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:id="@+id/iv_dialog_sina_bg"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:scaleType="fitXY"
    />
  <ImageButton
    android:id="@+id/ib_dialog_sina_close"
    android:layout_width="15dp"
    android:layout_height="15dp"
    android:src="@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:id="@+id/ll_dialog_sina_menu"
    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:id="@+id/ll_dialog_sina_write"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:orientation="vertical"
      android:gravity="center_horizontal"
      >
      <ImageView
        android:layout_width="75dp"
        android:layout_height="75dp"
        android:src="@drawable/dialog_sina_send_write"
        />

      <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:textSize="13sp"
        android:textColor="@color/text_gray"
        android:text="一般内容"
        android:layout_marginTop="8dp"

        />
    </LinearLayout>
    <LinearLayout
      android:id="@+id/ll_dialog_sina_time"
      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"
      >
      <ImageView
        android:layout_width="75dp"
        android:layout_height="75dp"
        android:src="@drawable/dialog_sina_send_time"
        />

      <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:textSize="13sp"
        android:textColor="@color/text_gray"
        android:text="时间胶囊"
        android:layout_marginTop="8dp"

        />
    </LinearLayout>
    <LinearLayout
      android:id="@+id/ll_dialog_sina_map"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:orientation="vertical"
      android:gravity="center_horizontal"
      >
      <ImageView
        android:layout_width="75dp"
        android:layout_height="75dp"
        android:src="@drawable/dialog_sina_send_map"
        />

      <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:textSize="13sp"
        android:textColor="@color/text_gray"
        android:text="地点胶囊"
        android:layout_marginTop="8dp"

        />
    </LinearLayout>

  </LinearLayout>

  <ImageView
    android:id="@+id/iv_dialog_sina_des"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:src="@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>

工具方法


  
  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;
  }


  
  public Bitmap getScreenShot(Activity activity) {
    // 获取windows中最顶层的view
    View view = activity.getWindow().getDecorView();
    view.buildDrawingCache();

    // 获取状态栏高度
    Rect rect = new Rect();
    view.getWindowVisibleDisplayFrame(rect);
    int statusBarHeights = rect.top;
    Display display = activity.getWindowManager().getDefaultDisplay();

    // 获取屏幕宽和高
    int widths = display.getWidth();
    int heights = display.getHeight();

    // 允许当前窗口保存缓存信息
    view.setDrawingCacheEnabled(true);

    // 去掉状态栏
    Bitmap bmp = Bitmap.createBitmap(view.getDrawingCache(), 0,
        0, widths, heights);

    // 销毁缓存信息
    view.destroyDrawingCache();

    return bmp;
  }


  
  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();
}

基本讲一下逻辑,背景采用截屏高斯模糊处理,这里一定要降图片质量,不然会慢,按钮采用一个动画从上向下划出,虽然不是特别完美,但是多少有个样子。

源码地址:

https://GitHub.com/bertsir/SinaSendView

到这里就结束啦.

以上就是Android仿新浪微博发送菜单界面的实现的详细内容,更多关于Android 发送菜单界面的实现的资料请关注编程网其它相关文章!

--结束END--

本文标题: Android仿新浪微博发送菜单界面的实现

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

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

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

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

下载Word文档
猜你喜欢
  • Android仿新浪微博发送菜单界面的实现
    目录效果图自定义Dialog布局文件Style工具方法接口效果图 接下来就是一波贴代码的过程 自定义Dialog public class SinaSendView exten...
    99+
    2024-04-02
  • 实现仿新浪微博箭头的css写法
    这篇文章主要介绍“实现仿新浪微博箭头的css写法”,在日常操作中,相信很多人在实现仿新浪微博箭头的css写法问题上存在疑惑,小编查阅了各式资料,整理出简单好用的操作方法,希望对大家解答”实现仿新浪微博箭头的...
    99+
    2024-04-02
  • Android实现微博菜单弹出效果
    先上Android仿微博菜单弹出效果图,这个截图不是很流畅,大家可以下载apk试一下。 说一下实现思路: 截取当前窗口,对图片做高斯模糊处理,将处理后的图片做popupwindow的背景图片; 2、创建popupwindow,完成...
    99+
    2023-05-30
    android 菜单弹出
  • android 仿微信demo——微信主界面实现
    目录主界面实现测试总结 以往文章中实现微信启动页,登录注册功能,此基础上继续完善仿微信功能。 主界面实现 (1)整体采用RelativeLayout相对布局 (2)最上面是too...
    99+
    2024-04-02
  • Android实现新浪微博一键分享的实例代码
    写在本章前愈来愈多的APP支持一键分享至QQ空间、微信朋友圈、新浪微博的功能,同时支持第三方账号登录,如QQ、微信、新浪微博等第三方平台的账号。本章结合当下流行的设计,兼顾免费的开源ShareSDK,结合项目中的实际需求,整合出一套分享源码...
    99+
    2023-05-30
    android 微博分享 roi
  • Android ListView实现仿微信聊天界面
    本篇内容主要讲解“Android ListView实现仿微信聊天界面”,感兴趣的朋友不妨来看看。本文介绍的方法操作简单快捷,实用性强。下面就让小编来带大家学习“Android ListView实现仿微信聊天界面”吧!Android List...
    99+
    2023-06-20
  • android 仿微信demo——微信启动界面实现
    目录微信启动界面创建项目微信启动界面实现测试总结微信启动界面 创建项目 android studio创建移动端项目 微信启动界面实现 当第一次点击微信时会看到微信出现启动界...
    99+
    2024-04-02
  • android 仿微信demo——微信消息界面实现(移动端)
    目录移动端微信消息页实现总结移动端微信消息页实现 在上一篇中主界面实现说过微信四个页面中间都是是fragment的,并且四个fragment的布局都还没实现,所以这一篇主要实现微信...
    99+
    2024-04-02
  • android 仿微信demo——微信消息界面实现(服务端)
    目录服务端微信消息页实现测试总结 上一篇实现了移动端微信消息界面功能,以此为基础继续完善服务端功能 服务端微信消息页实现 微信消息界面的实现,和登录,注册是类似的,无非就是接受客...
    99+
    2024-04-02
  • DIV+CSS实现仿DreamWeaver界面图形菜单效果的示例分析
    这篇文章给大家分享的是有关DIV+CSS实现仿DreamWeaver界面图形菜单效果的示例分析的内容。小编觉得挺实用的,因此分享给大家做个参考,一起跟随小编过来看看吧。这是一款DIV+CSS实现的图形菜单仿DreamWeaver效果,做了兼...
    99+
    2023-06-09
  • Android Studio实现仿微信APP门户界面详解及源码
    目录前言界面分析界面动态实现代码静态界面实现总结前言 你好! 本文章主要介绍如何用Android Studio制作简易的门户界面,主要说明框架的各部分功能与实现过程,结尾处附有源码。...
    99+
    2024-04-02
  • IOS开发仿微信消息长按气泡菜单实现效果
    目录正文使用方法导入项目使用对比微信实现效果正文 话不多说,直接上效果图 使用方法 导入项目 代码地址:github.com/shangjie119… 将SJPopM...
    99+
    2024-04-02
  • android 仿微信demo——微信通讯录界面功能实现(移动端,服务端)
    目录移动端微信通讯录界面功能实现服务端微信通讯录界面功能实现测试总结 前面我们实现了微信消息界面的实现,这篇继续完善微信功能,实现微信通讯录界面 移动端微信通讯录界面功能实现 微信...
    99+
    2024-04-02
  • uniapp模仿微信实现聊天界面的示例代码
    目录项目演示前言主界面chat.vue中引入的js文件chat.vue中引入的组件submit.vue中引入的组件最后项目演示 前言 我是看B站的视频一个一个敲的,讲的还不错。可以...
    99+
    2024-04-02
  • Android动态更新Menu菜单的实现过程
    目录1. 需求描述2. 基础知识3. 菜单加载4. 需求实现5. 总结1. 需求描述 Android Menu菜单是比较常见的功能,在ActionBar  or ToolB...
    99+
    2024-04-02
  • Android如何模仿实现微博详情页滑动固定顶部栏的效果
    这篇文章主要介绍了Android如何模仿实现微博详情页滑动固定顶部栏的效果,具有一定借鉴价值,感兴趣的朋友可以参考下,希望大家阅读完这篇文章之后大有收获,下面让小编带着大家一起了解一下。先来看下我们今天要实现的效果:滑动固定顶部栏效果图这段...
    99+
    2023-05-30
    android
  • vue仿网易云音乐播放器界面的简单实现过程
    由于工作项目的需要,需要使用到歌曲播放,参考多方资料,写了一个仿网易云音乐播放界面,能完整的实现音乐播放功能。 前端简单的使用vue组件和audio标签实现了播放器界面,后端则是...
    99+
    2024-04-02
  • PHP开发买菜系统的配送员管理与派单功能实现方法
    随着电商行业的快速发展和人们对便捷生活的需求不断增加,线上购买食材已经成为一种新的消费趋势。而为了提供更好的服务和更高的效率,买菜系统的开发变得非常重要。在买菜系统中,配送员管理和派单功能是核心要素之一,本文将介绍PHP开发买菜系统的配送员...
    99+
    2023-11-03
    PHP开发 配送员管理 派单功能
  • PHP开发买菜系统的订单配送路线规划功能实现方法
    随着互联网和移动技术的发展,线上购物已成为人们生活的一部分。而日常买菜服务也逐渐走入了线上,方便了人们的生活。然而,对于买菜系统来说,实现订单配送路线规划功能是一项非常重要的任务。本文将介绍使用PHP开发买菜系统的订单配送路线规划功能的实现...
    99+
    2023-11-01
    PHP开发 - PHP编程语言开发 订单配送 - 订单配送管理 路线规划 - 路线规划算法
  • Android实现简单的登陆页面(最新版2023详细图文教程
      目录   1.打开android studio软件  2.新建empty activity 3.看个人配置填(finish)  4.左侧找到res->layout(页面布局)  5.先设置页面布局,这里采用线性布局  7.设置头文本 ...
    99+
    2023-09-09
    android java android studio
软考高级职称资格查询
编程网,编程工程师的家园,是目前国内优秀的开源技术社区之一,形成了由开源软件库、代码分享、资讯、协作翻译、讨论区和博客等几大频道内容,为IT开发者提供了一个发现、使用、并交流开源技术的平台。
  • 官方手机版

  • 微信公众号

  • 商务合作