티스토리 뷰


위와 같이 TabLayout 아래에 ViewPager 를 두고 싶었는데, ViewPager 가 계속 TabLayout 을 침범했다 

아래와 같이 나오는 것이었다. 



<android.support.v4.view.ViewPager
android:id="@+id/container"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_constraintStart_toStartOf="@+id/tabs"
app:layout_constraintTop_toBottomOf="@+id/tabs">

</android.support.v4.view.ViewPager>

여기서 

    android:layout_height="match_parent"

android:layout_height="wrap_content"

로 바꾸어서 해결했다.


XML 전문


<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">


<android.support.design.widget.TabLayout

android:id="@+id/tabs"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_constraintBottom_toTopOf="@+id/container"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent">

</android.support.design.widget.TabLayout>

<android.support.v4.view.ViewPager
android:id="@+id/container"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_constraintStart_toStartOf="@+id/tabs"
app:layout_constraintTop_toBottomOf="@+id/tabs">

</android.support.v4.view.ViewPager>


</android.support.constraint.ConstraintLayout>


댓글