可能这个标题会误导大家,但是又知道博客标题起什么好,微博相信大家都很爱玩,而且微博很多好玩的东西,为我们无聊的生活添加点乐趣,微博正文有个功能就是我们向下拖动的时候,标题栏下面会悬挂一个评论.转发,赞,的功能,当我们向上滑动到一定高度后这个又自动消失,如图:
无行中逛泡在网上的日子 这个论坛,看到关于这篇文章,就下载下来了,看了相关代码,发现设计的很巧妙,可能我们会想通过什么自定义来实现,现在简单的画一个图分析它的实现方式:
这个关键是在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&