自定义view__封装Dialog-分享功能UI的实现

本文介绍了如何使用RecyclerView、SVG和MaterialDialog封装一个自定义的分享功能Dialog。通过RecyclerView便于增删分享项,SVG提高绘制效率,实现简洁流畅的界面。主要代码包括ShareInfo、ShareAdapter、ShareDialog等,只需在MainActivity中调用即可展示并监听点击事件。
摘要由CSDN通过智能技术生成

直接上图看效果
这里写图片描述

GitHub下载
实现的思路

  1. recyclerView–可以方便的添加多个分享,方便增加修改
  2. svg–svg可减少使得绘制更快,更流畅
  3. materialDialog–简洁大方

因为分享功能可能需要增加或修改,所以使用recyclerView来显示

看源码
item_share.xml

<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent" android:layout_height="wrap_content">
    <android.support.v7.widget.AppCompatImageView
        android:id="@+id/img_share"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:minHeight="42dp"
        android:minWidth="42dp"
        app:srcCompat="@drawable/ic_moments"
        android:layout_marginLeft="8dp"
        app:layout_constraintLeft_toLeftOf="parent"
        app:layout_constraintTop_toTopOf="parent"
        android:layout_marginTop="8dp"
        android:layout_marginRight="8dp"
        app:layout_constraintRight_toRightOf="parent" />
    <TextView
        android:id="@+id/tvShare"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_marginBottom="8dp"
        android:layout_marginLeft="8dp"
        android:layout_marginRight="8dp"
        android:layout_marginTop="8dp"
        android:text="盆友圈"
        android:gravity="center_horizontal"
  • 2
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值