17

पर CollapsingToolBarCoordinatorLayout के अंदर उपयोग कर रहा है और मेरे पास है जिसमें बच्चे के विचारों के रूप में EditText शामिल हैं। मुझे जो सामना करना पड़ रहा है वह है जब संपादन केंद्रित हो जाता है और कीबाबार्ड मेरा पूरा दृश्य दिखाई देता है, वह स्क्रॉल नहीं करता है।CollapsingToolbarLayout को तब नहीं गिर रहा है जब संपादन टेक्स्ट को

नीचे उस लेआउट के आउटपुट के रूप में कोड और छवि है।

<android.support.design.widget.AppBarLayout 
    android:id="@+id/appbar" 
    android:layout_width="match_parent" 
    android:layout_height="@dimen/app_bar_height" 
    android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"> 

    <android.support.design.widget.CollapsingToolbarLayout 
     android:id="@+id/collapsing_toolbar" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     app:expandedTitleMarginEnd="64dp" 
     app:expandedTitleMarginStart="48dp" 
     app:contentScrim="?attr/colorPrimary" 
     app:layout_scrollFlags="scroll|exitUntilCollapsed"> 


     <ImageView 
      android:id="@+id/ivProductImage" 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" 
      android:scaleType="centerCrop" 
      android:src="@drawable/stub_image" 
      app:layout_collapseParallaxMultiplier="0.7" 
      app:layout_collapseMode="parallax" /> 

     <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/nested_scroll_view" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    app:layout_behavior="@string/appbar_scrolling_view_behavior"> 

    <LinearLayout 
     android:id="@+id/containerLayout" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:orientation="vertical" 
     app:layout_behavior="@string/appbar_scrolling_view_behavior"> 

     <android.support.design.widget.TextInputLayout 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:layout_marginLeft="10dp" 
      android:layout_marginRight="10dp" 
      android:layout_marginTop="10dp"> 

      <EditText 
       android:id="@+id/etProductTitle" 
       style="@style/EditTextStyle" 
       android:hint="@string/lbl_product_title" 
       android:inputType="text" 
       android:textSize="24dp" /> 
     </android.support.design.widget.TextInputLayout> 

     <android.support.design.widget.TextInputLayout 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:layout_marginLeft="10dp" 
      android:layout_marginRight="10dp"> 

      <EditText 
       android:id="@+id/etProductDescription" 
       style="@style/EditTextStyle" 
       android:hint="@string/lbl_description" 
       android:inputType="text" /> 
     </android.support.design.widget.TextInputLayout> 

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

      <android.support.design.widget.TextInputLayout 
       android:layout_width="0dp" 
       android:layout_height="wrap_content" 
       android:layout_marginLeft="10dp" 
       android:layout_marginRight="10dp" 
       android:layout_weight="0.5"> 

       <EditText 
        android:id="@+id/etDeposit" 
        style="@style/EditTextStyle" 
        android:hint="@string/lbl_deposit" 
        android:inputType="number" /> 
      </android.support.design.widget.TextInputLayout> 

      <android.support.design.widget.TextInputLayout 
       android:layout_width="0dp" 
       android:layout_height="wrap_content" 
       android:layout_marginLeft="10dp" 
       android:layout_marginRight="10dp" 
       android:layout_weight="0.5"> 

       <EditText 
        android:id="@+id/etPricePerDay" 
        style="@style/EditTextStyle" 
        android:hint="@string/lbl_price_per_day" 
        android:inputType="number" /> 
      </android.support.design.widget.TextInputLayout> 
     </LinearLayout> 

     <android.support.design.widget.TextInputLayout 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:layout_marginLeft="10dp" 
      android:layout_marginRight="10dp"> 

      <EditText 
       android:id="@+id/etLocation" 
       style="@style/EditTextStyle" 
       android:hint="@string/lbl_add_location" 
       android:inputType="text" /> 
     </android.support.design.widget.TextInputLayout> 

     <TextView 
      style="@style/SubHeading" 
      android:layout_margin="10dp" 
      android:text="@string/lbl_categories" 
      android:textColor="@color/color_primary" /> 

     <android.support.v7.widget.RecyclerView 
      android:id="@+id/recyclerView" 
      android:layout_width="match_parent" 
      android:layout_height="315dp" 
      android:layout_marginLeft="10dp" 
      android:isScrollContainer="false" 
      android:layout_marginRight="10dp" 
      android:scrollbars="none" /> 

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

enter image description here

+0

हाय, मैं एक ही मुद्दा है, आप इसे हल किया? – streamride

+0

मैं रीसाइक्लर व्यू को हटाकर 'नेस्डस्क्रोल व्यू' के अंदर 'रीसाइक्लर व्यू' का उपयोग कर रहा था, मेरी समस्या हल हो गई। –

उत्तर

2

RecyclerView (, लेकिन RecyclerViewNestedScrollingChild का एक बच्चा है) एक स्क्रॉल विजेट जिसका अर्थ है, इन स्क्रॉल विगेट्स eachother के साथ काम नहीं करेगा है।

अधिक स्पष्टीकरण के लिए इस प्रश्न को जांचें:

How to use RecyclerView inside NestedScrollView?

लेकिन, आप कस्टमLinearLayoutManager

https://stackoverflow.com/a/32736113/4409113


वैसे साथ उपयोग कर सकते हैं,

आप 0 कि इस्तेमाल कर सकते हैं CoordinatorLayout के अंदर और NestedScrollView के बाहर।

उम्मीद है कि मदद करता है।

1

मैं EditText को OnFocusChangeListener जोड़कर इस संकल्प लिया और दिया है अगर यह ध्यान केंद्रित है - बस setExpanded विधि के साथ दृश्य पतन:

editText.setOnFocusChangeListener(new View.OnFocusChangeListener() { 
    @Override 
    public void onFocusChange(final View v, boolean hasFocus) { 
     if (hasFocus) { 
      mAppBarLayout.setExpanded(false, true); 
     } 
    } 
}); 

यदि आप चाहते हैं कि आपके CollapsingToolbarLayout हर बार ध्वस्त हो गई हो जब अपने अन्य EditText के से आपका लेआउट केंद्रित हो जाता है, तो आपको उनमें से प्रत्येक को OnFocusChangeListener सेट करना चाहिए।

+2

यह सबसे अच्छा समाधान जैसा प्रतीत होता है, लेकिन 'mAppBarLayout.setExpanded (false)' का उपयोग करके 'CollapsingToolbarLayout' को बस पतन करना आसान होना चाहिए। – TR4Android

+0

कारण मैंने 'setExpanded' विधि का उपयोग नहीं किया है यह है कि यह विधि केवल डिज़ाइन लाइब्रेरी के v23 संस्करण में दिखाई दी है, लेकिन मैंने इसे पहले लागू किया है। – rom4ek

0

मुझे लगता है कि सभी शोध के बाद यह सबसे अच्छा समाधान

editText.setOnFocusChangeListener(new View.OnFocusChangeListener() { 
@Override 
public void onFocusChange(final View v, boolean hasFocus) { 
    if (hasFocus) { 
     mAppBarLayout.setExpanded(false, true); // second one for animation 
    } 
} 
}); 
संबंधित मुद्दे

 संबंधित मुद्दे