布局如下:上面是一个描述有:头像和部分信息的布局,底部是一个RecyclerView;
想法:想实现RecyclerView向上滚动的时候,隐藏上面的头像布局信息;使用了
CoordinatorLayout AppBarLayout可以实现;AppBarLayout包裹需要滑动隐藏的布局,并设置需要滚动布局的app:layout_scrollFlags="scroll|enterAlways"属性
这里可以实现:RecycleView向上滑动时隐藏,但是如果RecycleView向下滑动,并没有滑动到顶部时,头像所在的布局就会跟着滚动下来。
起初以为可以设置layout_scrollFlags来避免这个问题,更换了下面的好像都不行
<!-- Scroll 表示向下滚动时,这个View会被滚出屏幕范围直到隐藏. enterAlways 表示向上滚动时,这个View会随着滚动手势出现,直到恢复原来的位置. app:layout_scrollFlags="scroll|enterAlways"
layout_scrollFlags中的几个值: scroll: 所有想滚动出屏幕的view都需要设置这个flag, 没有设置这个flag的view将被固定在屏幕顶部。 enterAlways:这个flag让任意向下的滚动都会导致该view变为可见,启用快速“返回模式”。 enterAlwaysCollapsed:当你的视图已经设置minHeight属性又使用此标志时,你的视图只能已最小高度进入,只有当滚动视图到达顶部时才扩大到完整高度。 exitUntilCollapsed:滚动退出屏幕,最后折叠在顶端。
【注意】: 设置了layout_scrollFlags标志的View必须在没有设置的View的之前定义,这样可以确保设置过的View都从上面移出, 只留下那些固定的View在下面。
app:layout_scrollFlags="scroll|enterAlways" 使用这个属性;当底部RecyclerView没有滑动到顶部的时候,要隐藏的布局就会自动出现; 想要实现的目的:在RecyclerView滑动到顶部时,隐藏的布局才出现
app:layout_scrollFlags="scroll|exitUntilCollapsed" 使用上面的属性会显得卡顿
enterAlwaysCollapsed:属性:滑动到顶部时,有时不会自动出现;并且SwipeRefreshLayout的刷新事件也会调用 -->
所以采用了ScrollView包裹,头布局和RecycleView的形式;但是:如果采用这个形式:ScrollView和RecycleView的滑动事件就会出现冲突;导致RecycleView向上滑动的时候特别卡顿。
其中遇到ScrollView和RecycleView上拉加载跟滑动冲突的事件,网上找到的方法:将RecycleView的滑动事件屏蔽,交给了ScrollView来执行
其中RecycleView的上拉加载事件,也就要交给ScrollView来实现;网上找到的是自定义了ScrollView,代码如下:
/** * 屏蔽 滑动事件 * Created by fc on 2015/7/16. */ public class MyScrollView extends ScrollView { private int downX; private int downY; private int mTouchSlop; public boolean isTop() { return isTop; } public void setTop(boolean top) { isTop = top; } private boolean isTop = false;//是不是滑动到了最低端 ;使用这个方法,解决了上拉加载的问题 private OnScrollToBottomListener onScrollToBottom; public MyScrollView(Context context) { super(context); mTouchSlop = ViewConfiguration.get(context).getScaledTouchSlop(); } public MyScrollView(Context context, AttributeSet attrs) { super(context, attrs); mTouchSlop = ViewConfiguration.get(context).getScaledTouchSlop(); } public MyScrollView(Context context, AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); mTouchSlop = ViewConfiguration.get(context).getScaledTouchSlop(); } @Override protected void onOverScrolled(int scrollX, int scrollY, boolean clampedX, boolean clampedY) { super.onOverScrolled(scrollX, scrollY, clampedX, clampedY); if(scrollY != 0 && null != onScrollToBottom &&isTop()){ onScrollToBottom.onScrollBottomListener(clampedY); } } public void setOnScrollToBottomLintener(OnScrollToBottomListener listener){ onScrollToBottom = listener; } public interface OnScrollToBottomListener{ public void onScrollBottomListener(boolean isBottom); } @Override public boolean onInterceptTouchEvent(MotionEvent e) { int action = e.getAction(); switch (action) { case MotionEvent.ACTION_DOWN: setTop(false); downX = (int) e.getRawX(); downY = (int) e.getRawY(); Log.i("-----::----downY-----::",downY+""); break; case MotionEvent.ACTION_MOVE: int moveY = (int) e.getRawY(); Log.i("-----::----moveY-----::",moveY+"");
/****判断是向下滑动,才设置为true****/ if(downY-moveY>0){ setTop(true); }else{ setTop(false); } if (Math.abs(moveY - downY) > mTouchSlop) { return true; } } return super.onInterceptTouchEvent(e); } }
调用代码
public class ScrollingActivity extends AppCompatActivity implements SwipeRefreshLayout.OnRefreshListener { private FullyLinearLayoutManager layoutManager; private int lastVisibleItem = 0; private boolean isover = false; private SwipeRefreshLayout srfl_my_dynamic; private MyScrollView scrollView;//含有头的头布局和RecyclerView的 private RecyclerView lvHpDynamicPost; // private AppBarLayout appbar;//上推隐藏;下拉显示的头布局 private RelativeLayout rl_head_bg;//表示标题头 private int currentPage = 0;//定义当前页为第1页 private int pageSize = 20;//定义每页加载20条 private MadeListAdapter dynamticListAdapter;//动态适配器 private ArrayList<String> dataList; @TargetApi(Build.VERSION_CODES.M) @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_scrolling); /*Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); setSupportActionBar(toolbar);*/ srfl_my_dynamic = (SwipeRefreshLayout) findViewById(R.id.srfl_my_dynamic); scrollView = (MyScrollView) findViewById(R.id.scrollView); scrollView.smoothScrollTo(0, 0); lvHpDynamicPost = (RecyclerView) findViewById(R.id.recview); rl_head_bg = (RelativeLayout) findViewById(R.id.rl_head_bg); //设置刷新时动画的颜色,可以设置4个 srfl_my_dynamic.setColorSchemeResources(android.R.color.holo_blue_light, android.R.color.holo_red_light, android.R.color.holo_orange_light, android.R.color.holo_green_light); scrollView.setOnScrollToBottomLintener(new MyScrollView.OnScrollToBottomListener() { @Override public void onScrollBottomListener(boolean isBottom) {
/**这里遇到一个问题,当数据加载完成后,向上滑动ScrollView,还会提示一遍“没有更多数据了”,所以多加了一个向下滑动的标记isTop;如果是判断向下滑动,并且isBottom是滑动到了最低端才加载数据**/ if (isBottom&&scrollView.isTop()) { //GetToast.showToast(ScrollingActivity.this,isBottom+""); if (srfl_my_dynamic.isRefreshing()) { srfl_my_dynamic.setRefreshing(false); } currentPage++; if (currentPage <= 4) { queryDynamtic(currentPage); } else { GetToast.showToast(ScrollingActivity.this, "没有更多数据了"); } }else{ //GetToast.showToast(ScrollingActivity.this,isBottom+""); } } }); lvHpDynamicPost.setHasFixedSize(true); layoutManager = new FullyLinearLayoutManager(this); layoutManager.setOrientation(LinearLayoutManager.VERTICAL); layoutManager.setSmoothScrollbarEnabled(true); lvHpDynamicPost.setLayoutManager(layoutManager); dataList = new ArrayList<>(); queryDynamtic(currentPage); dynamticListAdapter = new MadeListAdapter(dataList); lvHpDynamicPost.addItemDecoration(new DividerItemDecoration( this, LinearLayoutManager.HORIZONTAL, 10, getResources().getColor(R.color.colorPrimary))); srfl_my_dynamic.setOnRefreshListener(this); /*lvHpDynamicPost.addOnScrollListener(new OnVerticalScrollListener() );*/ lvHpDynamicPost.setAdapter(dynamticListAdapter); } private void queryDynamtic(int currentPage) { for (int i = currentPage * 20 + currentPage; i < 20 + currentPage * 20; i++) { dataList.add("张三莉莉" + i); } if (null != dynamticListAdapter) { dynamticListAdapter.notifyDataSetChanged(); } } @Override public boolean onOptionsItemSelected(MenuItem item) { // Handle action bar item clicks here. The action bar will // automatically handle clicks on the Home/Up button, so long // as you specify a parent activity in AndroidManifest.xml. int id = item.getItemId(); //noinspection SimplifiableIfStatement if (id == R.id.action_settings) { return true; } return super.onOptionsItemSelected(item); } /** * RecyclerView 滚动到顶端 * * @param recyclerView * @return */ public static boolean isSlideToTop(RecyclerView recyclerView) { return recyclerView.computeVerticalScrollOffset() <= 0; } @Override public void onRefresh() { currentPage = 0; GetToast.showToast(ScrollingActivity.this, String.valueOf(currentPage)); dataList.clear(); queryDynamtic(currentPage); if (srfl_my_dynamic.isRefreshing()) { srfl_my_dynamic.setRefreshing(false); } } /****(上滑 up)(下滑 down)(顶部 top)(底部 bottom) * 这个方法利用了View的一个方法。public boolean canScrollVertically (int direction) 这个方法是判断View在竖直方向是否还能 向上,向下 滑动。 根据上面的例子,应该可以看出。 -1 表示 向上, 1 表示向下。 同理还有 public boolean canScrollHorizontally (int direction) 方法用来判断 水平方向的滑动。 具体的使用方法可以参考 官方文档 实现这个自定义的Listener之后你就可以在RecycyclerView的setOnScrollListener方法中使用了,像系统的使用方法一样。 * ****/ /*public class OnVerticalScrollListener extends RecyclerView.OnScrollListener { @Override public final void onScrolled(RecyclerView recyclerView, int dx, int dy) { //解决RecyclerView和SwipeRefreshLayout共用存在的bug srfl_my_dynamic.setEnabled(layoutManager.findFirstCompletelyVisibleItemPosition() == 0); if (!recyclerView.canScrollVertically(-1)) { onScrolledToTop(); } else if (!recyclerView.canScrollVertically(1)) { onScrolledToBottom(); } else if (dy < 0) { onScrolledUp(); } else if (dy > 0) { onScrolledDown(); } } public void onScrolledUp() { } public void onScrolledDown() { } public void onScrolledToTop() { isTop = true; Toast.makeText(ScrollingActivity.this, "滑动到了顶端", Toast.LENGTH_SHORT).show(); } public void onScrolledToBottom() { Toast.makeText(ScrollingActivity.this, "底部", Toast.LENGTH_SHORT).show(); //if (newState == RecyclerView.SCROLL_STATE_IDLE ) { if (srfl_my_dynamic.isRefreshing()) { srfl_my_dynamic.setRefreshing(false); } currentPage++; if (currentPage <= 4) { Toast.makeText(ScrollingActivity.this, currentPage + "", Toast.LENGTH_SHORT).show(); queryDynamtic(currentPage); } else { Toast.makeText(ScrollingActivity.this, "没有更多数据了", Toast.LENGTH_SHORT).show(); } //} } } */ static class ViewHolder extends RecyclerView.ViewHolder { TextView tv_zan; ViewHolder(View view) { super(view); tv_zan= (TextView) view.findViewById(android.R.id.text1); } } private class MadeListAdapter extends RecyclerView.Adapter{ ArrayList<String> data; public MadeListAdapter(ArrayList<String> data) { this.data = data; } @Override public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { View view = LayoutInflater.from(parent.getContext()).inflate(android.R.layout.simple_list_item_1, null); LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT); view.setLayoutParams(lp); return new ViewHolder(view); } @Override public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) { ViewHolder viewHolder = (ViewHolder) holder; String text= data.get(position); viewHolder.tv_zan.setText(text); } @Override public long getItemId(int position) { return position; } @Override public int getItemCount() { return data.size(); } } /*protected boolean isSlideToBottom(RecyclerView recyclerView) { if (recyclerView == null) return false; if (recyclerView.computeVerticalScrollExtent() + recyclerView.computeVerticalScrollOffset() >= recyclerView.computeVerticalScrollRange()) return true; return false; } @Override public void onOffsetChanged(AppBarLayout appBarLayout, int i) { //super.onOffsetChanged(appBarLayout, i); 如果您使用的是LinearLayoutManager或StaggeredGridLayoutManager, 它们都有一个scrollToPositionWithOffset(int position,int offset)方法,第一个参数是item的position值, 第二个参数是第一个参数对应的item距离RecyclerView的顶部(Top)的距离(px) if (srfl_my_dynamic == null) return; layoutManager.scrollToPositionWithOffset(0,10); if(isSlideToTop(lvHpDynamicPost)){ srfl_my_dynamic.setEnabled(i >= 0 ? true : false); //appbar.setVisibility(View.VISIBLE); }else{ //appbar.setVisibility(View.GONE); } } */ }
设置RecycleView的分割线样式
/** * Created by amssy on 2016/7/18. */ public class DividerItemDecoration extends RecyclerView.ItemDecoration { private Paint mPaint; private Drawable mDivider; private int mDividerHeight = 2;//分割线高度,默认为1px private int mOrientation;//列表的方向:LinearLayoutManager.VERTICAL或LinearLayoutManager.HORIZONTAL private static final int[] ATTRS = new int[]{android.R.attr.listDivider}; /** * 默认分割线:高度为2px,颜色为灰色 * * @param context * @param orientation 列表方向 */ public DividerItemDecoration(Context context, int orientation) { if (orientation != LinearLayoutManager.VERTICAL && orientation != LinearLayoutManager.HORIZONTAL) { throw new IllegalArgumentException("请输入正确的参数!"); } mOrientation = orientation; final TypedArray a = context.obtainStyledAttributes(ATTRS); mDivider = a.getDrawable(0); a.recycle(); } /** * 自定义分割线 * * @param context * @param orientation 列表方向 * @param drawableId 分割线图片 */ public DividerItemDecoration(Context context, int orientation, int drawableId) { this(context, orientation); mDivider = ContextCompat.getDrawable(context, drawableId); mDividerHeight = mDivider.getIntrinsicHeight(); } /** * 自定义分割线 * * @param context * @param orientation 列表方向 * @param dividerHeight 分割线高度 * @param dividerColor 分割线颜色 */ public DividerItemDecoration(Context context, int orientation, int dividerHeight, int dividerColor) { this(context, orientation); mDividerHeight = dividerHeight; mPaint = new Paint(Paint.ANTI_ALIAS_FLAG); mPaint.setColor(dividerColor); mPaint.setStyle(Paint.Style.FILL); } //获取分割线尺寸 @Override public void getItemOffsets(Rect outRect, View view, RecyclerView parent, RecyclerView.State state) { super.getItemOffsets(outRect, view, parent, state); outRect.set(0, 0, 0, mDividerHeight); } //绘制分割线 @Override public void onDraw(Canvas c, RecyclerView parent, RecyclerView.State state) { super.onDraw(c, parent, state); if (mOrientation == LinearLayoutManager.VERTICAL) { drawVertical(c, parent); } else { drawHorizontal(c, parent); } } //绘制横向 item 分割线 private void drawHorizontal(Canvas canvas, RecyclerView parent) { final int left = parent.getPaddingLeft(); final int right = parent.getMeasuredWidth() - parent.getPaddingRight(); final int childSize = parent.getChildCount(); for (int i = 0; i < childSize; i++) { final View child = parent.getChildAt(i); RecyclerView.LayoutParams layoutParams = (RecyclerView.LayoutParams) child.getLayoutParams(); final int top = child.getBottom() + layoutParams.bottomMargin; final int bottom = top + mDividerHeight; if (mDivider != null) { mDivider.setBounds(left, top, right, bottom); mDivider.draw(canvas); } if (mPaint != null) { canvas.drawRect(left, top, right, bottom, mPaint); } } } //绘制纵向 item 分割线 private void drawVertical(Canvas canvas, RecyclerView parent) { final int top = parent.getPaddingTop(); final int bottom = parent.getMeasuredHeight() - parent.getPaddingBottom(); final int childSize = parent.getChildCount(); for (int i = 0; i < childSize; i++) { final View child = parent.getChildAt(i); RecyclerView.LayoutParams layoutParams = (RecyclerView.LayoutParams) child.getLayoutParams(); final int left = child.getRight() + layoutParams.rightMargin; final int right = left + mDividerHeight; if (mDivider != null) { mDivider.setBounds(left, top, right, bottom); mDivider.draw(canvas); } if (mPaint != null) { canvas.drawRect(left, top, right, bottom, mPaint); } } } }
布局代码
<android.support.v4.widget.SwipeRefreshLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" android:id="@+id/srfl_my_dynamic" android:layout_width="match_parent" android:layout_height="match_parent"> <!--<android.support.design.widget.CoordinatorLayout android:id="@+id/coorLayout" android:layout_width="match_parent" android:layout_height="match_parent" > <android.support.design.widget.AppBarLayout android:id="@+id/appbar" android:layout_width="match_parent" android:layout_height="wrap_content" android:background="#00ff99">--> <test.demo.com.view.MyScrollView android:id="@+id/scrollView" android:layout_width="match_parent" android:layout_height="wrap_content" android:background="#ffffff"> <!-- Scroll 表示向下滚动时,这个View会被滚出屏幕范围直到隐藏. enterAlways 表示向上滚动时,这个View会随着滚动手势出现,直到恢复原来的位置. app:layout_scrollFlags="scroll|exitUntilCollapsed" 使用上面的属性会显得卡顿 app:layout_scrollFlags="scroll|enterAlways" layout_scrollFlags中的几个值: scroll: 所有想滚动出屏幕的view都需要设置这个flag, 没有设置这个flag的view将被固定在屏幕顶部。 enterAlways:这个flag让任意向下的滚动都会导致该view变为可见,启用快速“返回模式”。 enterAlwaysCollapsed:当你的视图已经设置minHeight属性又使用此标志时,你的视图只能已最小高度进入,只有当滚动视图到达顶部时才扩大到完整高度。 exitUntilCollapsed:滚动退出屏幕,最后折叠在顶端。 【注意】: 设置了layout_scrollFlags标志的View必须在没有设置的View的之前定义,这样可以确保设置过的View都从上面移出, 只留下那些固定的View在下面。 app:layout_scrollFlags="scroll|enterAlways" 使用这个属性;当底部RecyclerView没有滑动到顶部的时候,要隐藏的布局就会自动出现; 想要实现的目的:在RecyclerView滑动到顶部时,隐藏的布局才出现 enterAlwaysCollapsed:属性:滑动到顶部时,有时不会自动出现;并且SwipeRefreshLayout的刷新事件也会调用 --> <LinearLayout android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" > <RelativeLayout android:id="@+id/rl_head_bg" android:layout_width="match_parent" android:layout_height="286dp" android:minHeight="286dp" app:layout_scrollFlags="scroll" android:background="@mipmap/beijing2x" android:orientation="horizontal"> <RelativeLayout android:id="@+id/rl_back" android:layout_width="45dp" android:layout_height="65dp"> <ImageView android:id="@+id/iv_back" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginLeft="8dp" android:layout_marginTop="20dp" android:background="@mipmap/public_back_btn_down"/> </RelativeLayout> <FrameLayout android:id="@+id/ll_head" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="horizontal" android:layout_gravity="bottom" android:gravity="center" android:layout_centerHorizontal="true"> <LinearLayout android:layout_alignParentBottom="true" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" android:layout_gravity="center" android:gravity="center" android:layout_centerHorizontal="true"> <ImageView android:id="@+id/iv_head" android:layout_width="90dp" android:layout_height="90dp" android:layout_marginTop="3dp" android:layout_alignTop="@+id/rl_back" android:layout_centerHorizontal="true" android:src="@mipmap/moren_head_icon" android:gravity="center" /> <TextView android:id="@+id/tv_name" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginTop="6dp" android:gravity="center_vertical" android:text="哈哈哈魔女" android:textColor="@android:color/white" android:textSize="20sp" /> <TextView android:id="@+id/tv_hp_express_company" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginTop="6dp" android:gravity="center_vertical" android:textColor="@android:color/white" android:text="魔女俱乐部" android:textSize="14sp" /> <TextView android:id="@+id/tv_hp_express_part" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginTop="6dp" android:layout_marginBottom="10dp" android:text="集训营" android:gravity="center_vertical" android:textColor="@android:color/white" android:textSize="14sp" /> <ImageView android:id="@+id/btn_concern" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginBottom="10dp" android:gravity="center_vertical" android:textSize="14sp" /> </LinearLayout> </FrameLayout> <LinearLayout android:layout_alignParentBottom="true" android:layout_width="match_parent" android:layout_height="56dp" android:orientation="horizontal" android:background="@android:color/darker_gray" android:layout_gravity="center" android:layout_centerHorizontal="true"> <!--关注布局--> <LinearLayout android:id="@+id/ll_concern_tt" android:layout_width="0dp" android:layout_weight="1" android:layout_marginTop="6dp" android:layout_height="wrap_content" android:orientation="vertical" android:gravity="center" android:layout_centerHorizontal="true"> <TextView android:id="@+id/tv_hp_sendPageCount_tt" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginTop="2dp" android:gravity="center_vertical" android:textColor="@android:color/white" android:text="他的关注" android:textSize="16sp" /> <TextView android:id="@+id/tv_hp_send_tt" android:layout_width="wrap_content" android:layout_height="wrap_content" android:gravity="center_vertical" android:layout_marginBottom="3dp" android:text="66" android:textColor="@android:color/white" android:textSize="16sp" /> </LinearLayout> <TextView android:layout_width="0.5dp" android:layout_weight="0.001" android:layout_height="match_parent" android:layout_marginTop="6dp" android:layout_marginBottom="6dp" android:background="@android:color/white" /> <!--粉丝布局--> <LinearLayout android:id="@+id/ll_fans_tt" android:layout_width="0dp" android:layout_weight="1" android:layout_marginTop="6dp" android:layout_height="wrap_content" android:orientation="vertical" android:gravity="center"> <TextView android:id="@+id/tv_hp_takePageCount_tt" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginTop="2dp" android:gravity="center" android:text="他的粉丝" android:textColor="@android:color/white" android:textSize="16sp" /> <TextView android:id="@+id/tv_hp_take_tt" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center" android:textColor="@android:color/white" android:layout_marginBottom="3dp" android:text="3" android:textSize="16sp" /> </LinearLayout> </LinearLayout> </RelativeLayout> <android.support.v7.widget.RecyclerView android:id="@+id/recview" android:layout_width="match_parent" android:layout_height="wrap_content" app:layout_behavior="@string/appbar_scrolling_view_behavior" > </android.support.v7.widget.RecyclerView> </LinearLayout> </test.demo.com.view.MyScrollView> </android.support.v4.widget.SwipeRefreshLayout> <!-- </android.support.design.widget.CoordinatorLayout>--> <!-- <?xml version="1.0" encoding="utf-8"?> <android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical"> <android.support.design.widget.AppBarLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="vertical"> <android.support.v7.widget.Toolbar android:id="@+id/third_activity_toolbar" android:layout_width="match_parent" android:layout_height="?attr/actionBarSize" /> <android.support.design.widget.TabLayout android:id="@+id/tab_layout" android:layout_width="match_parent" android:layout_height="wrap_content" app:layout_scrollFlags="scroll|enterAlways" app:tabIndicatorColor="@color/medium_blue" app:tabSelectedTextColor="@color/medium_blue" app:tabTextAppearance="@style/TabText" app:tabTextColor="@color/gray_text" /> </android.support.design.widget.AppBarLayout> <android.support.v4.view.ViewPager android:id="@+id/viewpager" android:layout_width="match_parent" android:layout_height="wrap_content" app:layout_behavior="@string/appbar_scrolling_view_behavior" /> </android.support.design.widget.CoordinatorLayout>-->