It just a Render Bug, So cant' work preview in android studio. But It run with properly.
If remove the CollapsingToolbarLayout then, it work rendering. but with CollapsingToolbarLayout not work rendering.
const val appcompatVersion = "1.2.0"
const val constraintVersion = "1.1.3"
const val materialVersion = "1.1.0"
It is a error message It is a error message It is a error message
java.lang.NullPointerException
at android.view.ViewGroup.brokenDispatchApplyWindowInsets(ViewGroup.java:7200)
at android.view.ViewGroup.dispatchApplyWindowInsets(ViewGroup.java:7193)
at android.view.ViewGroup.brokenDispatchApplyWindowInsets(ViewGroup.java:7203)
at android.view.ViewGroup.dispatchApplyWindowInsets(ViewGroup.java:7193)
at android.view.ViewGroup.brokenDispatchApplyWindowInsets(ViewGroup.java:7203)
at android.view.ViewGroup.dispatchApplyWindowInsets(ViewGroup.java:7193)
at android.view.ViewGroup.brokenDispatchApplyWindowInsets(ViewGroup.java:7203)
at android.view.ViewGroup.dispatchApplyWindowInsets(ViewGroup.java:7193)
at android.view.ViewGroup.brokenDispatchApplyWindowInsets(ViewGroup.java:7203)
at android.view.ViewGroup.dispatchApplyWindowInsets(ViewGroup.java:7193)
at android.view.ViewRootImpl.dispatchApplyInsets(ViewRootImpl.java:1925)
at android.view.ViewRootImpl_Accessor.dispatchApplyInsets(ViewRootImpl_Accessor.java:24)
at com.android.layoutlib.bridge.impl.Layout.requestFitSystemWindows(Layout.java:385)
at android.view.View.requestFitSystemWindows(View.java:10796)
at android.view.View.requestFitSystemWindows(View.java:10796)
at android.view.View.requestFitSystemWindows(View.java:10796)
at android.view.View.requestFitSystemWindows(View.java:10796)
at android.view.View.requestApplyInsets(View.java:10804)
at androidx.core.view.ViewCompat.requestApplyInsets(ViewCompat.java:2426)
at androidx.core.view.ViewCompat$Api21Impl$1.onApplyWindowInsets(ViewCompat.java:4774)
at android.view.View.dispatchApplyWindowInsets(View.java:10514)
at android.view.ViewGroup.dispatchApplyWindowInsets(ViewGroup.java:7191)
at android.view.ViewGroup.brokenDispatchApplyWindowInsets(ViewGroup.java:7203)
at android.view.ViewGroup.dispatchApplyWindowInsets(ViewGroup.java:7193)
at android.view.ViewGroup.brokenDispatchApplyWindowInsets(ViewGroup.java:7203)
at android.view.ViewGroup.dispatchApplyWindowInsets(ViewGroup.java:7193)
at android.view.ViewGroup.brokenDispatchApplyWindowInsets(ViewGroup.java:7203)
at android.view.ViewGroup.dispatchApplyWindowInsets(ViewGroup.java:7193)
at android.view.ViewGroup.brokenDispatchApplyWindowInsets(ViewGroup.java:7203)
at android.view.ViewGroup.dispatchApplyWindowInsets(ViewGroup.java:7193)
at android.view.ViewRootImpl.dispatchApplyInsets(ViewRootImpl.java:1925)
at android.view.ViewRootImpl_Accessor.dispatchApplyInsets(ViewRootImpl_Accessor.java:24)
at com.android.layoutlib.bridge.impl.Layout.requestFitSystemWindows(Layout.java:385)
at android.view.View.requestFitSystemWindows(View.java:10796)
at android.view.View.requestFitSystemWindows(View.java:10796)
at android.view.View.requestFitSystemWindows(View.java:10796)
at android.view.View.requestFitSystemWindows(View.java:10796)
at android.view.View.requestFitSystemWindows(View.java:10796)
at android.view.View.requestApplyInsets(View.java:10804)
at androidx.core.view.ViewCompat.requestApplyInsets(ViewCompat.java:2426)
at com.google.android.material.appbar.CollapsingToolbarLayout.onAttachedToWindow(CollapsingToolbarLayout.java:264)
at android.view.View.dispatchAttachedToWindow(View.java:19575)
at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:3430)
at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:3437)
at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:3437)
at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:3437)
at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:3437)
at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:3437)
at android.view.AttachInfo_Accessor.setAttachInfo(AttachInfo_Accessor.java:44)
at com.android.layoutlib.bridge.impl.RenderSessionImpl.inflate(RenderSessionImpl.java:360)
at com.android.layoutlib.bridge.Bridge.createSession(Bridge.java:404)
at com.android.tools.idea.layoutlib.LayoutLibrary.createSession(LayoutLibrary.java:141)
at com.android.tools.idea.rendering.RenderTask.createRenderSession(RenderTask.java:713)
at com.android.tools.idea.rendering.RenderTask.lambda$inflate$6(RenderTask.java:844)
at java.util.concurrent.CompletableFuture$AsyncSupply.run(CompletableFuture.java:1604)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:748)
I write the code below.
<androidx.coordinatorlayout.widget.CoordinatorLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#color/white"
android:paddingBottom="13dp">
<com.google.android.material.appbar.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#null"
android:elevation="0dp">
<com.google.android.material.appbar.CollapsingToolbarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_scrollFlags="scroll|exitUntilCollapsed">
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="?android:attr/actionBarSize"
app:layout_collapseMode="parallax">
//content
</androidx.constraintlayout.widget.ConstraintLayout>
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="?actionBarSize"
android:background="#fff"
app:layout_collapseMode="pin">
//Just View (I used this container like a toolbar)
</androidx.constraintlayout.widget.ConstraintLayout>
</com.google.android.material.appbar.CollapsingToolbarLayout>
<com.google.android.material.tabs.TabLayout
style="#style/TabLayout"
android:layout_width="0dp"
android:layout_height="wrap_content" />
</com.google.android.material.appbar.AppBarLayout>
<androidx.viewpager2.widget.ViewPager2
android:layout_width="match_parent"
android:layout_height="match_parent"
android:clipToPadding="false"
android:overScrollMode="never"
app:layout_behavior="#string/appbar_scrolling_view_behavior" />
</androidx.coordinatorlayout.widget.CoordinatorLayout>
Why trouble for me?
Related
My fragment inside collpasetoolbar not working when recyclerview scrolls, I tried all but get no success. I do not know what can I do anymore.
To explain my recyclerview is in another file bellow collpasetoolbar as included file inside a coordinator layout.
There is my XML code and I cannot make its works!
...
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.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:id="#+id/productLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="br.com.product.feature.product.ProductActivity">
<androidx.appcompat.widget.Toolbar
android:id="#+id/toolbar"
style="#style/DefaultConstraintToolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
<include
android:id="#+id/viewToolbarSearch"
layout="#layout/product_view_toolbar_search"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="#dimen/design_default"
android:layout_marginEnd="#dimen/design_default"
android:layout_marginBottom="#dimen/design_default" />
</androidx.appcompat.widget.Toolbar>
<ViewFlipper
android:id="#+id/viewFlipperProductList"
android:layout_width="match_parent"
android:layout_height="0dp"
app:layout_constraintBottom_toTopOf="#id/tabBar"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#id/toolbar">
<androidx.coordinatorlayout.widget.CoordinatorLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<com.google.android.material.appbar.AppBarLayout
android:id="#+id/appBarLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:fitsSystemWindows="true"
app:elevation="0dp">
<com.google.android.material.appbar.CollapsingToolbarLayout
android:id="#+id/toolbar_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="#dimen/margin16dp"
android:background="#color/design_white"
app:contentScrim="#color/design_white"
app:layout_collapseMode="pin"
app:layout_scrollFlags="scroll|enterAlways">
<androidx.fragment.app.FragmentContainerView
android:id="#+id/fragment_container_header_product"
class="br.com.product.feature.product.adapter.ProductListViewSetupFragment"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_collapseMode="parallax"
app:layout_collapseParallaxMultiplier="0.7"
tools:layout="#layout/activity_product_header" />
</com.google.android.material.appbar.CollapsingToolbarLayout>
</com.google.android.material.appbar.AppBarLayout>
<br.concrete.base.ui.component.productListing.ProductListingView
android:id="#+id/productListingView"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:displayAs="GridTwoColumns"
app:layout_behavior="#string/appbar_scrolling_view_behavior"
app:showDecoration="true" />
</androidx.coordinatorlayout.widget.CoordinatorLayout>
<include
layout="#layout/item_product_not_found"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<br.com.viavarejo.component.screenstate.ErrorStateView
android:id="#+id/page_try_again_product"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</ViewFlipper>
<include
android:id="#+id/tabBar"
layout="#layout/view_tab_bar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_constraintBottom_toBottomOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
I am trying to start a new activity but I am getting this error for the activity which I want to start. This XML code is for the activity which I want to start.
Here is the error log:
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.SandFoil.kaizen/com.SandFoil.kaizen.Registeration}: android.view.InflateException: Binary XML file line #94: addView(View, LayoutParams) is not supported in AdapterView
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2659)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2724)
at android.app.ActivityThread.-wrap12(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1473)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6123)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:867)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:757)
Caused by: android.view.InflateException: Binary XML file line #94: addView(View, LayoutParams) is not supported in AdapterView
Caused by: java.lang.UnsupportedOperationException: addView(View, LayoutParams) is not supported in AdapterView
at android.widget.AdapterView.addView(AdapterView.java:495)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:862)
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:821)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:861)
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:821)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:861)
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:821)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:861)
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:821)
at android.view.LayoutInflater.inflate(LayoutInflater.java:518)
at android.view.LayoutInflater.inflate(LayoutInflater.java:426)
at android.view.LayoutInflater.inflate(LayoutInflater.java:377)
at android.support.v7.app.AppCompatDelegateImplV9.setContentView(AppCompatDelegateImplV9.java:287)
at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:139)
at com.SandFoil.kaizen.Registeration.onCreate(Registeration.java:11)
at android.app.Activity.performCreate(Activity.java:6672)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1140)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2612)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2724)
at android.app.ActivityThread.-wrap12(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1473)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6123)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:867)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:757)
and here's my XML code
<?xml version="1.0" encoding="utf-8"?>
<ScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
tools:context="com.SandFoil.kaizen.Registeration"
android:id="#+id/activity_registeration"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:paddingLeft="8dp">
<android.support.design.widget.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Name">
<android.support.design.widget.TextInputEditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/registeration_name_edittext"
android:inputType="text"
android:textSize="20sp"
android:layout_marginBottom="10dp"/>
</android.support.design.widget.TextInputLayout>
<android.support.design.widget.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Phone">
<android.support.design.widget.TextInputEditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/registeration_phone_edittext"
android:inputType="phone"
android:textSize="20sp"
android:layout_marginBottom="10dp" />
</android.support.design.widget.TextInputLayout>
<android.support.design.widget.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="E-mail">
<android.support.design.widget.TextInputEditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/registeration_email_edittext"
android:inputType="textEmailAddress"
android:textSize="20sp"
android:layout_marginBottom="10dp" />
</android.support.design.widget.TextInputLayout>
<android.support.design.widget.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Date of birth(dd/mm/yyyy)">
<android.support.design.widget.TextInputEditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/registeration_date_of_birth_edittext"
android:inputType="date"
android:textSize="20sp"
android:layout_marginBottom="10dp" />
</android.support.design.widget.TextInputLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_marginBottom="10dp">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="20sp"
android:text="Gender: "
android:layout_marginRight="10dp"/>
<android.support.v7.widget.AppCompatSpinner
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<Spinner
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/registeration_gender_spinner"
android:layout_marginBottom="10dp">
</Spinner>
</android.support.v7.widget.AppCompatSpinner>
</LinearLayout>
<android.support.design.widget.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Mother's name('N/A' if you are not a student)">
<android.support.design.widget.TextInputEditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/registeration_mother_name_edittext"
android:inputType="text"
android:textSize="20sp"
android:layout_marginBottom="10dp" />
</android.support.design.widget.TextInputLayout>
<android.support.design.widget.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Child's name('N/A' if you are not a parent)">
<android.support.design.widget.TextInputEditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/registeration_child_name_edittext"
android:inputType="text"
android:textSize="20sp"
android:layout_marginBottom="10dp" />
</android.support.design.widget.TextInputLayout>
<android.support.design.widget.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Password">
<android.support.design.widget.TextInputEditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/registeration_password_edittext"
android:inputType="textPassword"
android:textSize="20sp"
android:layout_marginBottom="10dp" />
</android.support.design.widget.TextInputLayout>
<Button
android:background="#drawable/capsule_button"
android:layout_width="220dp"
android:layout_height="50dp"
android:text="Login"
android:textColor="#android:color/white"
android:textSize="25sp"
android:layout_marginBottom="10dp"/>
</LinearLayout>
</ScrollView>
Googled all possible solutions but none worked. Can somebody please fix this and tell me something about this issue ?? And Here is the java file for this XML
package com.SandFoil.kaizen;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
public class Registeration extends AppCompatActivity {
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_registeration);
}
}
The implementation of "spinner" is wrong here in XML. I copied that code from somewhere on the internet. I will be editing this answer and posting the link to that wrong implementation for reference as soon as i find it again. Remove that "spinner" code from this XML and it will work.
I have a problem with my collapsing toolbar. When I scroll up (toolbar is colapsing) it scrolls smoothly. Unfurtunately, when i scroll down (toolbar is expanding) scrolling stops waiting for nested scrolling view to get completely scrolled. I guess you will understand it with this GIF:
This is my XML:
<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:fab="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="#+id/vDrawer"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#color/background"
android:fitsSystemWindows="true"
tools:openDrawer="start">
<android.support.design.widget.CoordinatorLayout
android:id="#+id/vCoordinator"
style="#style/Layout.Coordinator"
tools:context="io.stepuplabs.settleup.ui.main.MainActivity">
<io.stepuplabs.settleup.ui.main.StateAwareAppBar
android:id="#+id/vAppBar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:fitsSystemWindows="true"
android:theme="#style/AppTheme.AppBarOverlay">
<android.support.design.widget.CollapsingToolbarLayout
android:id="#+id/vCollapsingToolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:fitsSystemWindows="true"
app:contentScrim="?attr/colorAccent"
app:layout_scrollFlags="scroll|enterAlways|enterAlwaysCollapsed|exitUntilCollapsed|snap">
<ImageView
android:id="#+id/vPlaceholderCircles"
android:layout_width="match_parent"
android:layout_height="296dp"
android:contentDescription="#string/desc_circles"
android:scaleType="centerCrop"
android:src="#drawable/placeholder"
app:layout_collapseMode="none"
/>
<android.support.v7.widget.Toolbar
android:id="#+id/vToolbar"
style="#style/Layout.Toolbar"
android:layout_marginBottom="40dp"
app:layout_collapseMode="pin"
app:layout_collapseParallaxMultiplier="1"
app:popupTheme="#style/AppTheme.PopupOverlay">
<TextView
android:id="#+id/vWhoShouldPayTitle"
android:layout_width="wrap_content"
android:visibility="gone"
android:layout_height="wrap_content"
android:layout_gravity="start"
android:text="#string/app_name"
android:textAppearance="#style/Text.Toolbar" />
</android.support.v7.widget.Toolbar>
<android.support.design.widget.TabLayout
android:id="#+id/vTabs"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
app:layout_collapseMode="parallax"
app:layout_collapseParallaxMultiplier="0"
app:tabIndicatorColor="#color/white"
app:tabMode="scrollable" />
</android.support.design.widget.CollapsingToolbarLayout>
</io.stepuplabs.settleup.ui.main.StateAwareAppBar>
<android.support.v4.view.ViewPager
android:id="#+id/vViewPager"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="#string/appbar_scrolling_view_behavior" />
<android.support.v4.widget.ContentLoadingProgressBar
android:id="#+id/vActivityProgress"
style="?android:attr/progressBarStyleLarge"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center" />
<com.github.clans.fab.FloatingActionMenu
android:id="#+id/vFloatingActionMenu"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="bottom|end"
android:contentDescription="#string/expense"
android:paddingBottom="10dp"
android:paddingLeft="10dp"
android:paddingRight="10dp"
app:layout_behavior="io.stepuplabs.settleup.ui.common.FloatingActionMenuBehavior"
fab:menu_animationDelayPerItem="0"
fab:menu_backgroundColor="#color/dim"
fab:menu_buttonSpacing="6dp"
fab:menu_fab_label="#string/expense"
fab:menu_icon="#drawable/fab_add"
fab:menu_labels_cornerRadius="30dp"
fab:menu_labels_ellipsize="end"
fab:menu_labels_paddingBottom="8dp"
fab:menu_labels_paddingLeft="16dp"
fab:menu_labels_paddingRight="16dp"
fab:menu_labels_paddingTop="8dp"
fab:menu_labels_position="left"
fab:menu_labels_textColor="#color/white"
fab:menu_labels_textSize="14sp">
<com.github.clans.fab.FloatingActionButton
android:id="#+id/vFabTransfer"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom|end"
android:contentDescription="#string/transfer"
android:src="#drawable/ic_transfer"
fab:fab_label="#string/transfer"
fab:fab_size="mini" />
</com.github.clans.fab.FloatingActionMenu>
</android.support.design.widget.CoordinatorLayout>
<android.support.design.widget.NavigationView
android:id="#+id/vNavigationDrawer"
android:layout_width="280dp"
android:layout_height="match_parent"
android:layout_gravity="start"
android:background="#color/white"
android:fitsSystemWindows="true"
app:headerLayout="#layout/drawer_header"
app:itemBackground="#drawable/selector_items_background_color"
app:itemIconTint="#color/selector_drawer_items_foreground_color"
app:itemTextColor="#color/selector_drawer_items_foreground_color"
app:menu="#menu/drawer" />
</android.support.v4.widget.DrawerLayout>
I'm trying to make a wrap_content RecyclerView, but it doesn't work.
I write this xml code:
<android.support.design.widget.CoordinatorLayout 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:fitsSystemWindows="true"
tools:context="br.com.moviee.activity.ItemActivity">
<android.support.design.widget.AppBarLayout
android:id="#+id/app_bar_layout"
android:layout_width="match_parent"
android:background="#android:color/transparent"
android:fitsSystemWindows="true"
android:layout_height="wrap_content"
android:theme="#style/AppTheme.AppBarOverlay">
<android.support.design.widget.CollapsingToolbarLayout
android:id="#+id/collapsing_toolbar"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_scrollFlags="scroll|exitUntilCollapsed"
app:contentScrim="?attr/colorPrimary"
app:expandedTitleMarginStart="48dp"
app:expandedTitleMarginEnd="64dp"
app:titleEnabled="true"
android:fitsSystemWindows="true">
<com.facebook.drawee.view.SimpleDraweeView
android:transitionName="#string/transition_poster"
android:id="#+id/poster"
android:layout_width="match_parent"
android:layout_height="400dp"
android:scaleType="centerCrop"
android:fitsSystemWindows="true"
app:layout_collapseMode="parallax"/>
<View
android:id="#+id/collapsing_comp"
android:layout_gravity="bottom"
android:layout_width="match_parent"
android:layout_height="140dp" />
<android.support.v7.widget.Toolbar
android:id="#+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
app:layout_collapseMode="pin"
app:popupTheme="#style/ThemeOverlay.AppCompat.Light" />
</android.support.design.widget.CollapsingToolbarLayout>
</android.support.design.widget.AppBarLayout>
<android.support.v4.widget.NestedScrollView
android:id="#+id/scroll"
android:fitsSystemWindows="true"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="#string/appbar_scrolling_view_behavior">
<include layout="#layout/content_item" />
</android.support.v4.widget.NestedScrollView>
<android.support.design.widget.FloatingActionButton
android:id="#+id/fab"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_anchor="#id/app_bar_layout"
app:layout_anchorGravity="bottom|right|end"
android:layout_margin="#dimen/fab_margin"
app:srcCompat="#android:drawable/ic_dialog_email" /></android.support.design.widget.CoordinatorLayout>
My RecyclerView Item xml:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<com.facebook.drawee.view.SimpleDraweeView
android:id="#+id/thumb_trailer"
android:scaleType="centerCrop"
android:layout_margin="1dp"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<ImageView
android:layout_gravity="center"
android:layout_centerVertical="true"
android:layout_centerHorizontal="true"
android:src="#drawable/ic_play_arrow"
android:layout_width="wrap_content"
android:layout_height="wrap_content" /></RelativeLayout>
And the content Layout
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
xmlns:tools="http://schemas.android.com/tools"
android:id="#+id/content_item"
android:layout_width="match_parent"
android:fitsSystemWindows="true"
android:layout_height="wrap_content"
tools:context="br.com.moviee.activity.ItemActivity"
tools:showIn="#layout/activity_item">
<include layout="#layout/card_main_information" />
<include layout="#layout/card_overview" />
<TextView
android:background="#android:color/white"
android:textStyle="bold"
android:textSize="14sp"
android:padding="16dp"
android:text="#string/title_trailer"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<android.support.v7.widget.RecyclerView
android:background="#android:color/white"
android:id="#+id/grid_trailer"
android:layout_width="match_parent"
android:layout_height="wrap_content" /></LinearLayout>
And write this java code:
private void configGrid() {
if(getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT)
layoutManager = new GridLayoutManager(this, Youtube.COLUM_NUMBER_PORTRAIT);
else
layoutManager = new GridLayoutManager(this, Youtube.COLUM_NUMBER_LANDSCAPE);
trailerGrid.setLayoutManager(layoutManager);
TrailerGridAdapter adapter = new TrailerGridAdapter(this);
trailerGrid.setAdapter(adapter);
trailerGrid.setHasFixedSize(true);
trailerGrid.setNestedScrollingEnabled(false);
}
I don't know why my Wrap_content RecyclerView doesn't work.
I am facing a weird problem related to view not found but everything seems to be right with the code (at least to me). Infact the program was working fine till some time back. I am not sure what change that i made causing this issue. Could anyone of you point me the problem? Thank you.
The below is the exception trace:
FATAL EXCEPTION: main
Process: co.mycompany, PID: 3923
java.lang.RuntimeException: Unable to start activity ComponentInfo{co.mycompany/co.mycompany.activities.MainActivity}: java.lang.RuntimeException: Unable to bind views for co.mycompany.activities.MainActivity
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2201)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2250)
at android.app.ActivityThread.access$800(ActivityThread.java:141)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1213)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5065)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:609)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.RuntimeException: Unable to bind views for co.mycompany.activities.MainActivity
at butterknife.ButterKnife.bind(ButterKnife.java:322)
at butterknife.ButterKnife.bind(ButterKnife.java:237)
at co.mycompany.activities.MainActivity.onCreate(MainActivity.java:51)
at android.app.Activity.performCreate(Activity.java:5249)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2165)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2250)
at android.app.ActivityThread.access$800(ActivityThread.java:141)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1213)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5065)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:609)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.IllegalStateException: Required view 'thUserProfilePic' with ID 2131558656 for field 'mUserProfilePic' was not found. If this view is optional add '#Nullable' annotation.
at butterknife.ButterKnife$Finder.findRequiredView(ButterKnife.java:140)
at co.mycompany.activities.MainActivity$$ViewBinder.bind(MainActivity$$ViewBinder.java:17)
at co.mycompany.activities.MainActivity$$ViewBinder.bind(MainActivity$$ViewBinder.java:8)
at butterknife.ButterKnife.bind(ButterKnife.java:319)
at butterknife.ButterKnife.bind(ButterKnife.java:237)
at co.mycompany.activities.MainActivity.onCreate(MainActivity.java:51)
at android.app.Activity.performCreate(Activity.java:5249)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2165)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2250)
at android.app.ActivityThread.access$800(ActivityThread.java:141)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1213)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5065)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:609)
at dalvik.system.NativeStart.main(Native Method)
MainActivity.class
#Bind(R.id.thUserProfilePic)
CircleImageView mUserProfilePic;
#Bind(R.id.thUserDisplayName)
TextView mUserDisplayName;
#Bind(R.id.editProfileLink)
ImageView editProfileLink;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
ButterKnife.bind(this);
setSupportActionBar(mToolbar);
ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(
this, mDrawerLayout, mToolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close);
mDrawerLayout.setDrawerListener(toggle);
toggle.syncState();
mNavigationView.setNavigationItemSelectedListener(this);
navigate(AppScreen.HOME);
}
R.layout.activity_main
<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.DrawerLayout 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:id="#+id/drawer_layout"
android:layout_width="match_parent" android:layout_height="match_parent"
android:fitsSystemWindows="true" tools:openDrawer="start">
<include layout="#layout/app_bar_main" android:layout_width="match_parent"
android:layout_height="match_parent" />
<android.support.design.widget.NavigationView android:id="#+id/nav_view"
android:layout_width="wrap_content" android:layout_height="match_parent"
android:layout_gravity="start" android:fitsSystemWindows="true"
app:headerLayout="#layout/nav_header_main" app:menu="#menu/activity_main_drawer"
android:background="#color/white"/>
</android.support.v4.widget.DrawerLayout>
R.layout.nav_header_main
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent" android:layout_height="#dimen/nav_header_height"
android:background="#drawable/side_nav_bar"
android:paddingBottom="#dimen/activity_vertical_margin"
android:paddingLeft="#dimen/activity_horizontal_margin"
android:paddingRight="#dimen/activity_horizontal_margin"
android:paddingTop="#dimen/activity_vertical_margin"
android:theme="#style/ThemeOverlay.AppCompat.Dark" android:orientation="vertical"
android:gravity="center">
<ImageView
android:id="#+id/editProfileLink"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/ic_edit_white_24dp"
android:layout_gravity="end|right"/>
<include layout="#layout/user_thumbnail_large"/>
</LinearLayout>
R.layout.user_thumnail_large
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content" android:layout_height="wrap_content"
android:orientation="vertical"
android:gravity="center_horizontal"
android:id="#+id/userThumbnailLargeContainer">
<de.hdodenhof.circleimageview.CircleImageView android:layout_width="75dp" android:layout_height="75dp"
android:paddingTop="#dimen/nav_header_vertical_spacing"
android:src="#drawable/ic_face_white_48dp" android:id="#+id/thUserProfilePic" />
<TextView android:layout_width="wrap_content" android:layout_height="wrap_content"
android:paddingTop="#dimen/nav_header_vertical_spacing" android:text="John"
android:textAppearance="#style/TextAppearance.AppCompat.Body1"
android:id="#+id/thUserDisplayName"
android:textColor="#color/textColorSecondary"/>
</LinearLayout>
I am into second day of research and could not able to figure out what the issue is.
The issue is with support Library version. I was getting the above error since i upgraded support library to 23 version.
The below link has the solution.
NavigationView get/find header layout