android文章详情评论,Android实现文章+评论.doc

Android实现文章评论

Android实现文章+评论(MVP,RxJava,Dagger2,ButterKnife)

简介

这个项目主要有两个功能,一个加载网页/文章,另一个用来显示评论。并应用了MVP模式,Dagger2、RxJava、ButterKnife等开源框架。

demo

结构

首先来看一下布局文件:

xmlns:app="/apk/res-auto"

xmlns:tools="/tools"

android:background="#ffffff"

android:layout_width="match_parent"

android:layout_height="match_parent"

android:fitsSystemWindows="true"

tools:context="com.dean.articlecomment.article.ArticleActivity">

android:id="@+id/app_bar"

android:layout_width="match_parent"

android:layout_height="wrap_content"

android:fitsSystemWindows="true"

android:theme="@style/AppTheme.AppBarOverlay">

android:id="@+id/toolbar"

android:fitsSystemWindows="true"

android:layout_width="match_parent"

android:layout_height="?attr/actionBarSize"

app:layout_scrollFlags="scroll|enterAlways"

app:popupTheme="@style/AppTheme.PopupOverlay" />

toolbar

在显示网页文章时是仿知乎的操作,向下滑动时隐藏toolbar和屏幕下方发表评论的视图,向上滚动时再显示。

toolbar的显示隐藏是通过设置其scrollFlags属性实现的。

enterAlways:向上滑时toolbar隐藏,向下滑动即展示。

enterAlwaysCollapsed:向上滑时toolbar隐藏,向下滑动直到NestedScrollView的底部时toolbar才展示。

exitUntilCollapsed:当你定义了一个minHeight,这个view将在滚动到达这个最小高度的时候消失。

snap:突然折断的意思,效果同enterAlwaysCollapsed,区别为滚动时手指离开屏幕时

toolbar不会显示一半的状态,显示的部分大于一半时即全漏出来,小于一半时即隐藏掉。

article_bottom_view

article_bottom_view是屏幕下方的评论条,它的隐藏显示与toolbar同步,使用方式是通过AppBarLayout.OnOffsetChangedListener的状态监听与动画实现的。

@Override

public void onOffsetChanged(AppBarLayout appBarLayout, int verticalOffset) {

if (verticalOffset >= 0) {

if (xAppBarListener != null) {

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值