2017-11-30 10 views
0

텍스트를 표시해야하고 하단에는 두 개의 탭이 필요합니다. 현재 코드는 텍스트가 작은 경우에만 작동합니다. 텍스트가 전체 화면을 채우는 경우 스크롤 할 때 탭이 표시되지 않습니다. enter image description here enter image description here 내 활동 XML은 다음과 같습니다NestedScrollView 안의 Android ViewPager

<?xml version="1.0" encoding="utf-8"?> 
<android.support.v4.widget.NestedScrollView 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" 
    android:fillViewport="true" 
    tools:context="dk.zispa.vibetasks.TaskDetailedView"> 

    <LinearLayout 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:orientation="vertical"> 

     <RelativeLayout 
      android:id="@+id/task_view_layout" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content"> 

      <TextView 
       android:id="@+id/taskTitle" 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" 
       android:layout_marginStart="5dp" 
       android:layout_marginTop="10dp" 
       android:clickable="true" 
       android:focusable="true" 
       android:textAppearance="?android:attr/textAppearanceMedium" 
       android:textColor="@color/black" 
       android:textSize="20sp" /> 

      <TextView 
       android:id="@+id/taskBreadcrumbs" 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" 
       android:layout_below="@id/taskTitle" 
       android:layout_marginStart="5dp" 
       android:layout_marginTop="3dp" 
       android:clickable="true" 
       android:focusable="true" 
       android:textAppearance="?android:attr/textAppearanceMedium" 
       android:textColor="@color/secondaryText" 
       android:textSize="14sp" /> 

      <View 
       android:id="@+id/divider" 
       android:layout_width="match_parent" 
       android:layout_height="1dp" 
       android:layout_below="@id/taskBreadcrumbs" 
       android:layout_marginBottom="10dp" 
       android:layout_marginTop="10dp" 
       android:background="@color/divider" /> 

      <TextView 
       android:id="@+id/taskDescription" 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" 
       android:layout_below="@id/divider" 
       android:layout_marginStart="5dp" 
       android:clickable="false" 
       android:focusable="false" 
       android:textAppearance="?android:attr/textAppearanceMedium" 
       android:textColor="@color/secondaryText" /> 

      <LinearLayout 
       android:id="@+id/hoursInfo" 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" 
       android:layout_below="@id/taskDescription" 
       android:layout_margin="5dp" 
       android:orientation="horizontal"> 

       <TextView 
        android:id="@+id/taskEstimatedHours" 
        android:layout_width="0dp" 
        android:layout_height="wrap_content" 
        android:layout_weight="1" 
        android:background="@color/orange" 
        android:gravity="center" 
        android:paddingBottom="3dp" 
        android:paddingTop="3dp" 
        android:textAppearance="?android:attr/textAppearanceMedium" 
        android:textColor="@color/white" /> 

       <TextView 
        android:id="@+id/taskWorkedHours" 
        android:layout_width="0dp" 
        android:layout_height="wrap_content" 
        android:layout_weight="1" 
        android:background="@color/colorPrimaryLight" 
        android:gravity="center" 
        android:paddingBottom="3dp" 
        android:paddingTop="3dp" 
        android:textAppearance="?android:attr/textAppearanceMedium" 
        android:textColor="@color/white" /> 

      </LinearLayout> 

     </RelativeLayout> 


     <android.support.v4.view.ViewPager 
      android:id="@+id/container" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:layout_below="@id/hoursInfo"> 

      <android.support.design.widget.TabLayout 
       android:id="@+id/book_tab_layout" 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" 
       app:tabGravity="fill"> 

       <android.support.design.widget.TabItem 
        android:id="@+id/book_description_tab_item" 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:text="TAB1" /> 

       <android.support.design.widget.TabItem 
        android:id="@+id/book_reviews_tab_item" 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:text="TAB2" /> 

      </android.support.design.widget.TabLayout> 
     </android.support.v4.view.ViewPager> 
    </LinearLayout> 


</android.support.v4.widget.NestedScrollView> 

당신이 아래로 스크롤 할 때 내가 탭 표시 할 수있는 방법 어떤 아이디어가 있습니까? 미리 감사드립니다.

답변

0

LinearLayout을 RelativeLayout으로 대체 할 수 있습니다. alignParentTop = "true"인 task_view_layout과 alignParentBottom = "true"및 layoutBelow = "@ + id/task_view_layout"뷰 페이저를 넣으십시오.

+0

스크롤하지 않으면 여전히 탭을 볼 수 없습니다. – vadber