佈局以下:上面是一個描述有:頭像和部分信息的佈局,底部是一個RecyclerView;android
想法:想實現RecyclerView向上滾動的時候,隱藏上面的頭像佈局信息;使用了express
CoordinatorLayout AppBarLayout能夠實現;AppBarLayout包裹須要滑動隱藏的佈局,並設置須要滾動佈局的app:layout_scrollFlags="scroll|enterAlways"屬性canvas
這裏能夠實現:RecycleView向上滑動時隱藏,可是若是RecycleView向下滑動,並無滑動到頂部時,頭像所在的佈局就會跟着滾動下來。app
起初覺得能夠設置layout_scrollFlags來避免這個問題,更換了下面的好像都不行ide
<!-- 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,代碼以下:ui
/** * 屏蔽 滑動事件 * 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); } }
調用代碼this
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的分割線樣式spa
/** * 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>-->