android - ViewPager doesnt work with a scrollView -


this layout add tablayout , viewpager inside scrollview .

everything ok , viewpager fragment doesn't show .

this xml layout :

<?xml version="1.0" encoding="utf-8"?> <relativelayout xmlns:android="http://schemas.android.com/apk/res/android"     xmlns:tools="http://schemas.android.com/tools"     android:layout_width="match_parent"     android:layout_height="match_parent">      <android.support.v7.widget.toolbar         android:id="@+id/toolbar"         android:layout_width="match_parent"         android:layout_height="wrap_content"         android:layout_alignparentleft="true"         android:layout_alignparentstart="true"         android:layout_alignparenttop="true"         android:background="@color/colorprimary">          <relativelayout             android:layout_width="match_parent"             android:layout_height="match_parent">              <textview                 android:id="@+id/tooltitle"                 android:layout_width="wrap_content"                 android:layout_height="wrap_content"                 android:textappearance="?android:textappearancelarge"                 android:textcolor="@android:color/white"                 android:textstyle="bold"                 tools:text="exemplo"                 android:layout_marginleft="12dp"                 android:layout_marginstart="12dp"                 android:layout_centervertical="true"                 android:layout_torightof="@+id/back_arrow"                 android:layout_toendof="@+id/back_arrow" />              <imageview                 android:paddingtop="2dp"                 android:layout_width="24dp"                 android:layout_height="24dp"                 android:layout_alignparentleft="true"                 android:layout_centervertical="true"                 android:src="@drawable/back_arrow"                 android:id="@+id/back_arrow" />         </relativelayout>      </android.support.v7.widget.toolbar>      <scrollview         android:layout_below="@id/toolbar"         android:layout_width="match_parent"         android:layout_height="match_parent"         android:fillviewport="true">      <relativelayout         android:layout_width="match_parent"         android:layout_height="wrap_content">          <imageview             android:id="@+id/restau_image"             android:layout_width="match_parent"             android:layout_height="210dp"             android:scaletype="centercrop"             tools:src="@drawable/catina2" />          <linearlayout             android:id="@+id/linear_clock"             android:layout_width="wrap_content"             android:layout_height="wrap_content"             android:layout_below="@id/restau_image"             android:layout_marginleft="16dp"             android:orientation="vertical">              <imageview                 android:id="@+id/clock"                 android:layout_width="36dp"                 android:layout_height="36dp"                 android:layout_marginbottom="8dp"                 android:layout_margintop="16dp"                 tools:src="@drawable/clock" />              <linearlayout                 android:layout_width="wrap_content"                 android:layout_height="wrap_content"                 android:layout_marginleft="4dp"                 android:orientation="horizontal">                  <textview                     android:id="@+id/almoco_textview"                     android:layout_width="wrap_content"                     android:layout_height="wrap_content"                     android:layout_marginright="8dp"                     android:textappearance="?android:textappearancemedium"                     android:textcolor="@android:color/black"                     android:textsize="18sp"                     android:textstyle="bold"                     tools:text="almoço" />                  <textview                     android:id="@+id/almoco_time"                     android:layout_width="wrap_content"                     android:layout_height="wrap_content"                     android:textappearance="?android:textappearancemedium"                     android:textcolor="@android:color/black"                     android:textsize="18sp"                     tools:text="11:30 - 14:30" />                  <imageview                     android:id="@+id/arrow_down"                     android:layout_width="28dp"                     android:layout_height="28dp"                     android:layout_marginleft="12dp"                     tools:src="@drawable/arow_down" />              </linearlayout>              <linearlayout                 android:layout_width="wrap_content"                 android:layout_height="wrap_content"                 android:layout_marginleft="4dp">                  <textview                     android:id="@+id/jantar_textview"                     android:layout_width="wrap_content"                     android:layout_height="wrap_content"                     android:layout_marginright="20dp"                     android:textappearance="?android:textappearancemedium"                     android:textcolor="@android:color/black"                     android:textsize="18sp"                     android:textstyle="bold"                     tools:text="jantar" />                  <textview                     android:id="@+id/jantar_time"                     android:layout_width="wrap_content"                     android:layout_height="wrap_content"                     android:textappearance="?android:textappearancemedium"                     android:textcolor="@android:color/black"                     android:textsize="18sp"                     tools:text="18:30 - 20:30" />              </linearlayout>              <textview                 android:id="@+id/open_option"                 android:layout_width="wrap_content"                 android:layout_height="wrap_content"                 android:layout_marginleft="4dp"                 android:layout_margintop="4dp"                 android:textappearance="?android:textappearancemedium"                 android:textcolor="@android:color/black"                 android:textsize="18sp"                 tools:text="aberto de segunda à sexta fechado aos feriados" />          </linearlayout>          <view             android:id="@+id/first_line"             android:layout_width="320dp"             android:layout_height="2dp"             android:layout_below="@id/linear_clock"             android:layout_centerhorizontal="true"             android:layout_margintop="8dp"             android:background="#bdbdbd">          </view>          <linearlayout             android:id="@+id/linear_info"             android:layout_width="wrap_content"             android:layout_height="wrap_content"             android:layout_below="@id/first_line"             android:layout_marginleft="16dp"             android:orientation="vertical">              <imageview                 android:id="@+id/info"                 android:layout_width="36dp"                 android:layout_height="36dp"                 android:layout_marginbottom="8dp"                 android:layout_margintop="16dp"                 tools:src="@drawable/info" />              <linearlayout                 android:layout_width="wrap_content"                 android:layout_height="wrap_content"                 android:layout_marginleft="4dp"                 android:orientation="horizontal">                  <textview                     android:id="@+id/pp_textview"                     android:layout_width="wrap_content"                     android:layout_height="wrap_content"                     android:textappearance="?android:textappearancemedium"                     android:textcolor="@android:color/black"                     android:textsize="18sp"                     tools:text="prato principal" />                  <textview                     android:id="@+id/pp_price"                     android:layout_width="wrap_content"                     android:layout_height="wrap_content"                     android:layout_marginleft="18dp"                     android:textappearance="?android:textappearancemedium"                     android:textcolor="@android:color/black"                     android:textsize="18sp"                     android:textstyle="bold"                     tools:text="3€" />              </linearlayout>              <linearlayout                 android:layout_width="wrap_content"                 android:layout_height="wrap_content"                 android:layout_marginleft="4dp"                 android:orientation="horizontal">                  <textview                     android:id="@+id/mp_textview"                     android:layout_width="wrap_content"                     android:layout_height="wrap_content"                     android:textappearance="?android:textappearancemedium"                     android:textcolor="@android:color/black"                     android:textsize="18sp"                     tools:text="mini prato" />                  <textview                     android:id="@+id/mp_price"                     android:layout_width="wrap_content"                     android:layout_height="wrap_content"                     android:layout_marginleft="52dp"                     android:textappearance="?android:textappearancemedium"                     android:textcolor="@android:color/black"                     android:textsize="18sp"                     android:textstyle="bold"                     tools:text="2.5€" />              </linearlayout>          </linearlayout>          <view             android:id="@+id/second_line"             android:layout_width="320dp"             android:layout_height="2dp"             android:layout_below="@id/linear_info"             android:layout_centerhorizontal="true"             android:layout_margintop="8dp"             android:background="#bdbdbd">          </view>          <linearlayout             android:layout_width="match_parent"             android:layout_height="wrap_content"             android:layout_below="@id/second_line"             android:orientation="vertical">              <android.support.design.widget.tablayout                 android:id="@+id/tabs"                 android:layout_width="match_parent"                 android:layout_height="wrap_content" />              <android.support.v4.view.viewpager                 android:id="@+id/viewpager"                 android:layout_width="match_parent"                 android:layout_height="wrap_content"                 android:layout_below="@id/tabs" />         </linearlayout>      </relativelayout>      </scrollview>  </relativelayout> 

as can see i've tried android:fillviewport="true", doesnt work... p.s im sorry long code, need solution fast possible... way seems work adding height in viewpager

your layout contents exceeds viewport(screen height) of scrollview. in type of layout structure thing can set fixed height viewpager. can view viewpager content. try below code viewpager

     <android.support.v4.view.viewpager                 android:id="@+id/viewpager"                 android:layout_width="match_parent"                 android:layout_height="300dp"                 android:layout_below="@id/tabs" /> 

Comments

Popular posts from this blog

resizing Telegram inline keyboard -

command line - How can a Python program background itself? -

php - "cURL error 28: Resolving timed out" on Wordpress on Azure App Service on Linux -