5

Ho questo layout con layout coordinatore, che ha schede con viewpager e in adattatore viewpager Creo recyclerview per ogni pagina.Layout di coordinatore con viewpager con recyclerview come adattatore

Disposizione:

08-09 11:28:17.816 2804-2804/com.xxx.yyy.debug  E/AndroidRuntime﹕ FATAL EXCEPTION: main 
java.lang.IllegalArgumentException: width and height must be > 0 
     at android.graphics.Bitmap.createBitmap(Bitmap.java:638) 
     at android.graphics.Bitmap.createBitmap(Bitmap.java:620) 
     at android.support.design.widget.CollapsingTextHelper.ensureExpandedTexture(CollapsingTextHelper.java:413) 
     at android.support.design.widget.CollapsingTextHelper.setInterpolatedTextSize(CollapsingTextHelper.java:390) 
     at android.support.design.widget.CollapsingTextHelper.calculateOffsets(CollapsingTextHelper.java:227) 
     at android.support.design.widget.CollapsingTextHelper.setExpansionFraction(CollapsingTextHelper.java:203) 
     at android.support.design.widget.CollapsingToolbarLayout$OffsetUpdateListener.onOffsetChanged(CollapsingToolbarLayout.java:768) 
     at android.support.design.widget.AppBarLayout$Behavior.dispatchOffsetUpdates(AppBarLayout.java:853) 
     at android.support.design.widget.AppBarLayout$Behavior.setAppBarTopBottomOffset(AppBarLayout.java:836) 
     at android.support.design.widget.AppBarLayout$Behavior.scroll(AppBarLayout.java:795) 
     at android.support.design.widget.AppBarLayout$Behavior.onNestedPreScroll(AppBarLayout.java:635) 
     at android.support.design.widget.AppBarLayout$Behavior.onNestedPreScroll(AppBarLayout.java:583) 
     at android.support.design.widget.CoordinatorLayout.onNestedPreScroll(CoordinatorLayout.java:1477) 
     at android.support.v4.view.ViewParentCompat$ViewParentCompatStubImpl.onNestedPreScroll(ViewParentCompat.java:106) 
     at android.support.v4.view.ViewParentCompat.onNestedPreScroll(ViewParentCompat.java:355) 
     at android.support.v4.view.NestedScrollingChildHelper.dispatchNestedPreScroll(NestedScrollingChildHelper.java:208) 
     at android.support.v7.widget.RecyclerView.dispatchNestedPreScroll(RecyclerView.java:8376) 
     at android.support.v7.widget.RecyclerView.onTouchEvent(RecyclerView.java:2191) 
     at android.view.View.dispatchTouchEvent(View.java:7205) 
     at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2231) 
     at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1964) 
     at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2237) 
     at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1979) 
     at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2237) 
     at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1979) 
     at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2237) 
     at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1979) 
     at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2237) 
     at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1979) 
     at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2237) 
     at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1979) 
     at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2237) 
     at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1979) 
     at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2237) 
     at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1979) 
     at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2237) 
     at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1979) 
     at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2237) 
     at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1979) 
     at com.android.internal.policy.impl.PhoneWindow$DecorView.superDispatchTouchEvent(PhoneWindow.java:2151) 
     at com.android.internal.policy.impl.PhoneWindow.superDispatchTouchEvent(PhoneWindow.java:1480) 
     at android.app.Activity.dispatchTouchEvent(Activity.java:2435) 
     at android.support.v7.internal.view.WindowCallbackWrapper.dispatchTouchEvent(WindowCallbackWrapper.java:59) 
     at android.support.v7.internal.view.WindowCallbackWrapper.dispatchTouchEvent(WindowCallbackWrapper.java:59) 
     at com.android.internal.policy.impl.PhoneWindow$DecorView.dispatchTouchEvent(PhoneWindow.java:2099) 
     at android.view.View.dispatchPointerEvent(View.java:7385) 
     at android.view.ViewRootImpl.deliverPointerEvent(ViewRootImpl.java:3398 

Qui ci sono i layout:

<?xml version="1.0" encoding="utf-8"?> 
    <android.support.v4.widget.DrawerLayout 
     xmlns:android="http://schemas.android.com/apk/res/android" 
     xmlns:tools="http://schemas.android.com/tools" 
     android:id="@+id/drawer" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:background="@color/turquoise_blue" 
     tools:context=".MainActivity"> 

    <include 
      layout="@layout/profile_content" /> 

    <include 
      layout="@layout/drawer_menu" /> 

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

e il layout dei contenuti profilo:

<?xml version="1.0" encoding="utf-8"?> 
<ui.screen.ProfileView 
     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.support.design.widget.CoordinatorLayout 
      android:id="@+id/content" 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" 
      android:orientation="vertical"> 

     <android.support.v4.view.ViewPager 
       android:id="@+id/profile_viewpager" 
       android:layout_width="match_parent" 
       android:layout_height="match_parent" 
       app:layout_behavior="@string/appbar_scrolling_view_behavior" /> 

     <android.support.design.widget.AppBarLayout 
       android:id="@+id/profile_appbar_layout" 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" 
       android:background="@android:color/transparent" 
       app:elevation="2dp" 
       > 

      <android.support.design.widget.CollapsingToolbarLayout 
        android:id="@+id/collapsing_toolbar" 
        android:layout_width="match_parent" 
        android:layout_height="match_parent" 
        app:contentScrim="?attr/colorPrimary" 
        app:layout_scrollFlags="scroll|exitUntilCollapsed" 
        app:expandedTitleTextAppearance="@android:color/transparent" 
        app:elevation="2dp"> 

       <LinearLayout 
         android:id="@+id/profile_user_layout" 
         android:layout_width="match_parent" 
         android:layout_height="192dp" 
         android:background="?attr/colorPrimary" 
         android:clipChildren="false" 
         android:clipToPadding="false" 
         android:orientation="vertical" 
         android:paddingBottom="24dp" 
         android:paddingLeft="24dp" 
         android:paddingRight="24dp" 
         android:paddingTop="64dp" 
         app:layout_collapseMode="parallax"> 

        <LinearLayout 
          android:layout_width="match_parent" 
          android:layout_height="wrap_content" 
          android:clipChildren="false" 
          android:orientation="horizontal"> 

         <FrameLayout 
           android:layout_width="96dp" 
           android:layout_height="96dp" 
           android:clipChildren="false"> 

          <de.hdodenhof.circleimageview.CircleImageView 
            android:id="@+id/profile_user_photo" 
            android:layout_width="86dp" 
            android:layout_height="86dp" 
            android:src="@mipmap/ic_launcher" 
            app:border_width="1dp" 
            app:border_color="@color/white"/> 

          <View 
            android:id="@+id/profile_user_medal" 
            android:layout_width="24dp" 
            android:layout_height="24dp" 
            android:background="@drawable/medal" 
            android:layout_marginRight="6dp" 
            android:layout_marginTop="2dp" 
            android:layout_gravity="top|right"/> 

         </FrameLayout> 

         <LinearLayout 
           android:id="@+id/profile_user_details" 
           android:layout_width="wrap_content" 
           android:layout_height="wrap_content" 
           android:layout_weight="1" 
           android:orientation="vertical" 
           android:layout_marginLeft="16dp"> 

          <TextView 
            android:id="@+id/profile_user_name" 
            android:layout_width="match_parent" 
            android:layout_height="wrap_content" 
            android:text="Kateřina Bíla" 
            android:textColor="@color/white" 
            android:textSize="24sp"/> 

          <TextView 
            android:id="@+id/profile_user_completed_activities" 
            android:layout_width="match_parent" 
            android:layout_height="wrap_content" 
            android:text="Dokoncene 4 z 5" 
            android:textColor="@color/white" 
            android:textSize="16sp"/> 

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

           <TextView 
             android:id="@+id/profile_user_progress_text" 
             android:layout_width="wrap_content" 
             android:layout_height="wrap_content" 
             android:textSize="20sp" 
             android:textColor="@color/white" 
             android:text="50%"/> 

           <com.rey.material.widget.ProgressView 
             android:id="@+id/profile_user_progress_bar" 
             android:layout_width="match_parent" 
             android:layout_height="6dp" 
             android:visibility="visible" 
             android:layout_gravity="center_vertical" 
             android:layout_marginLeft="8dp" 
             android:paddingRight="16dp" 
             app:pv_progressMode="determinate" 
             app:pv_circular="false" 
             app:pv_autostart="true" 
             app:lpd_strokeSize="3dp" 
             app:lpd_strokeColor="@color/red" 
             app:lpd_strokeSecondaryColor="@color/white" 
             app:lpd_maxLineWidth="62dp" 
             app:lpd_minLineWidth="31dp" 
             app:pv_progressStyle="@style/ProfileTotalProgressBar" 
             app:pv_progress="0.5"/> 


          </LinearLayout> 


         </LinearLayout> 
        </LinearLayout> 


       </LinearLayout> 

       <include 
        layout="@layout/toolbar" /> 

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

      <FrameLayout 
        android:layout_width="match_parent" 
        android:layout_height="48dp"> 

       <android.support.design.widget.TabLayout 
         android:id="@+id/profile_tab_layout" 
         android:layout_width="match_parent" 
         android:layout_height="48dp" 
         android:layout_gravity="top" 
         android:background="?attr/colorPrimary" 
         app:tabTextColor="@color/white_87" 
         app:tabGravity="fill" 
         app:tabIndicatorColor="@color/white" 
         app:tabIndicatorHeight="4dp" 
         app:tabMode="fixed" 
         app:tabSelectedTextColor="@color/white" 
         app:tabTextAppearance="@style/TabTextAppearance" 
       /> 

      </FrameLayout> 

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

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

</ui.screen.ProfileView> 

Il fatto è che questo accade solo su Samsung S3 mini. Ho provato più dispositivi come Nexus 5, Samsung Galaxy S6, alcuni vecchi dispositivi HTC, ma solo sul mini ho ricevuto questo errore mentre cercavo di scorrere verso l'alto con recyclerview. Non ottengo l'errore bitmap.

Modifica: ho effettuato ulteriori ricerche, questo problema sembra interessare tutti i dispositivi su API inferiori a KitKat.

+0

quale versione di librerie hai usato? aggiornali alla v22.0.1. molti bug sono stati corretti in questa versione. –

+0

@SinaKH com.android.support:design:22.2.1 –

+0

esattamente intendevo 22.2.1 ,, non so, per favore non dimenticare di inviare risposta qui se lo hai trovato, tnx :) –

risposta

2

Ho avuto questo problema oggi.

Sono finalmente riuscito a risolverlo. Nel mio caso è stato perché ho ottenuto textSize 0SP per rendere il testo invisibile nella modalità estesa: <style name="AdDetailExpandedTitleText" parent="@android:style/TextAppearance.Medium"> <item name="android:textColor">#FFFFFF</item> <item name="android:textSize">0sp</item> </style>

ho impostato il textSize a qualcosa di diverso 0SP, invece impostare il colore # 00000000 per renderlo trasparente.