android 仿新浪微博转发 评论悬浮框的功能

本文介绍了如何在Android应用中模仿新浪微博的下拉悬停评论和转发功能。当用户向下滚动时,标题栏下方会出现评论、转发等选项,并在向上滑动到一定高度后自动隐藏。实现这一功能的关键在于自定义ScrollerView,通过监听滑动事件,计算布局距离并判断是否应该显示悬停效果。相关代码示例包括MainActivity.java和CustomScrollView.java。
摘要由CSDN通过智能技术生成

可能这个标题会误导大家,但是又知道博客标题起什么好,微博相信大家都很爱玩,而且微博很多好玩的东西,为我们无聊的生活添加点乐趣,微博正文有个功能就是我们向下拖动的时候,标题栏下面会悬挂一个评论.转发,赞,的功能,当我们向上滑动到一定高度后这个又自动消失,如图:



无行中逛泡在网上的日子 这个论坛,看到关于这篇文章,就下载下来了,看了相关代码,发现设计的很巧妙,可能我们会想通过什么自定义来实现,现在简单的画一个图分析它的实现方式:


这个关键是在2这个部分,现在我们布局文件贴下,然后分析:

<com.zhimore.myscrollview.view.TopView xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/custom_top_view"
    android:layout_width="match_parent"
    android:layout_height="match_parent" >
    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical" >
        <ImageView
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:background="@drawable/meinv"
            android:contentDescription="@string/app_name"
             />
        <FrameLayout
            android:id="@+id/top"
            android:layout_width="match_parent"
            android:layout_height="wrap_content" 
            android:background="#66ffffff"
            >
            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:orientation="horizontal"
                android:padding="5dp" >
                <EditText
                    android:id="@+id/et"
                    android:layout_width="0dp"
                    android:layout_height="wrap_content"
                    android:layout_gravity="center"
                    android:layout_weight="1"
                    android:gravity="center"
                    android:hint="请输入你想搜的内容"
                    android:textSize&
  • 0
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值