problema con CollapsingToolbarLayout

newbie1980

Nuovo Utente
26 Ott 2016
2
0
1
44
Salve, quando apro la schermata dei prodotti l'app si crasha. Di seguito il logCat

E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.appdemo, PID: 14013
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.appdemo/com.example.appdemo.product}: android.view.InflateException: Binary XML file line #16: Error inflating class android.support.design.widget.CollapsingToolbarLayout
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2377)
...........................
Caused by: android.view.InflateException: Binary XML file line #16: Error inflating class android.support.design.widget.CollapsingToolbarLayout
at android.view.LayoutInflater.createView(LayoutInflater.java:620)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:696)
.............................................
at android.support.v7.app.AppCompatDelegateImplV7.setContentView(AppCompatDelegateImplV7.java:280)
at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:140)
at com.example.appdemo.product.onCreate(product.java:47)
at android.app.Activity.performCreate(Activity.java:5343)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1088)
..................................................
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:644)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.reflect.InvocationTargetException
at java.lang.reflect.Constructor.constructNative(Native Method)
at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
..........................................................
at android.support.v7.app.AppCompatDelegateImplV7.setContentView(AppCompatDelegateImplV7.java:280)
at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:140)
at com.example.appdemo.product.onCreate(product.java:47)
at android.app.Activity.performCreate(Activity.java:5343)
...............................................................
Caused by: java.lang.NoSuchMethodError: android.support.v4.graphics.drawable.DrawableCompat.setLayoutDirection
at android.support.design.widget.CollapsingToolbarLayout.setStatusBarScrim(CollapsingToolbarLayout.java:663)
at android.support.design.widget.CollapsingToolbarLayout.<init>(CollapsingToolbarLayout.java:197)
at android.support.design.widget.CollapsingToolbarLayout.<init>(CollapsingToolbarLayout.java:132)
at java.lang.reflect.Constructor.constructNative(Native Method)
at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
..............................................
at android.support.v7.app.AppCompatDelegateImplV7.setContentView(AppCompatDelegateImplV7.java:280)
at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:140)
at com.example.appdemo.product.onCreate(product.java:47)
....................................................
at dalvik.system.NativeStart.main(Native Method)

la riga che da errore è:
Codice:
setContentView(R.layout.product);

il problema è nel file product.xml, se elimino questa parte di codice:
Codice:
<android.support.design.widget.CollapsingToolbarLayout
    android:id="@+id/collapsing_toolbar"
    android:layout_height="match_parent"
    android:layout_width="match_parent"
    app:layout_scrollFlags="scroll|exitUntilCollapsed"
    app:contentScrim="@color/colorPrimary"
    app:expandedTitleMarginStart="48dp"
    app:expandedTitleMarginEnd="64dp">


    <ImageView
        android:id="@+id/backdrop"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:scaleType="centerCrop"
        android:transitionName="element1"
        android:background="@drawable/ferro"
        app:layout_collapseMode="parallax"/>

    <android.support.v7.widget.Toolbar
        android:id="@+id/tb_main"
        android:elevation="0dp"
        android:layout_height="?attr/actionBarSize"
        android:layout_width="match_parent"
        android:minHeight="?attr/actionBarSize"
        app:popupTheme="@style/ThemeOverlay.AppCompat.Dark"
        app:layout_collapseMode="pin"/>

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

Devo impostare qualcosa nel file product.java?

Come posso risolverlo?

Grazie
 

Discussioni simili