2015-11-07 16 views
20

से शुरू नहीं होगा I NestedScrollview में एक पुनर्चक्रण है .. सबकुछ एक थिग को छोड़कर ठीक काम कर रहा है। मेरे पास NestedScrollview में कुल तीन दृश्य हैं पहले दो रैखिकलाइट फिर रीसाइक्लिंगव्यू हैं। जब मैं अपना ऐप चलाता हूं तो गतिविधि शीर्ष दो लेआउट नहीं दिखाती है, यह रीसाइक्लिंगव्यू के शीर्ष से शुरू होती है।NestedScrollview शीर्ष

कैसे अपनी मेरी लेआउट दिखा:

How its show my layout

कैसे अपने को दिखाने के लिए लगता है:

How its suppose to show

और मैं एक viewpager के तहत इस enite लेआउट लोड हो रहा है कर रहा हूँ और मेरी viewpager एक बच्चा है समन्वयक लेआउट का।

<?xml version="1.0" encoding="utf-8"?> 
<android.support.v4.widget.NestedScrollView 
android:id="@+id/scrollView" 
android:layout_width="match_parent" 
android:layout_height="match_parent" 
android:background="@color/home_layout_background"> 

<LinearLayout 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:orientation="vertical"> 

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

     <com.daimajia.slider.library.SliderLayout 
      android:id="@+id/image_slider" 
      android:layout_width="match_parent" 
      android:layout_height="@dimen/image_slider_height" 
      android:layout_marginTop="@dimen/image_slider_top_margin" /> 
    </LinearLayout> 

    <LinearLayout 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:layout_marginLeft="@dimen/popular_fragment_side_padding" 
     android:layout_marginRight="@dimen/popular_fragment_side_padding" 
     android:layout_marginTop="@dimen/popular_fragment_side_padding" 
     android:orientation="horizontal" 
     android:weightSum="4"> 

     <RelativeLayout 
      android:layout_width="0dp" 
      android:layout_height="match_parent" 
      android:layout_weight="1"> 

      <RelativeLayout 
       android:id="@+id/free_delivery" 
       android:layout_width="76dp" 
       android:layout_height="76dp" 
       android:layout_centerInParent="true" 
       android:background="@color/white"> 

       <RelativeLayout 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:layout_centerInParent="true"> 

        <ImageView 
         android:id="@+id/btnImageViewFreeDelivery" 
         android:layout_width="wrap_content" 
         android:layout_height="wrap_content" 
         android:layout_centerHorizontal="true" 
         android:background="@drawable/icon_free_delivery" /> 

        <TextView 
         android:id="@+id/btnTextFreeDelivery" 
         android:layout_width="wrap_content" 
         android:layout_height="wrap_content" 
         android:layout_below="@+id/btnImageViewFreeDelivery" 
         android:layout_centerHorizontal="true" 
         android:layout_marginTop="2dp" 
         android:text="@string/free_delivery_txt" 
         android:textColor="@color/popular_fragment_four_btn_txt" 
         android:textSize="@dimen/popular_fragment_four_btn_txt_size" /> 
       </RelativeLayout> 

      </RelativeLayout> 

     </RelativeLayout> 

     <RelativeLayout 
      android:layout_width="0dp" 
      android:layout_height="match_parent" 
      android:layout_weight="1"> 

      <RelativeLayout 
       android:id="@+id/flash_deals" 
       android:layout_width="76dp" 
       android:layout_height="76dp" 
       android:layout_centerInParent="true" 
       android:background="@color/white"> 


       <RelativeLayout 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:layout_centerInParent="true"> 

        <ImageView 
         android:id="@+id/btnImageViewFlashDeals" 
         android:layout_width="wrap_content" 
         android:layout_height="wrap_content" 
         android:layout_centerHorizontal="true" 
         android:background="@drawable/icon_flash_deals" /> 

        <TextView 
         android:id="@+id/btnTextFlashDeals" 
         android:layout_width="wrap_content" 
         android:layout_height="wrap_content" 
         android:layout_below="@+id/btnImageViewFlashDeals" 
         android:layout_centerHorizontal="true" 
         android:layout_marginTop="2dp" 
         android:text="@string/flash_deals_txt" 
         android:textColor="@color/popular_fragment_four_btn_txt" 
         android:textSize="@dimen/popular_fragment_four_btn_txt_size" /> 
       </RelativeLayout> 

      </RelativeLayout> 

     </RelativeLayout> 

     <RelativeLayout 
      android:layout_width="0dp" 
      android:layout_height="match_parent" 
      android:layout_weight="1"> 

      <RelativeLayout 
       android:id="@+id/for_you" 
       android:layout_width="76dp" 
       android:layout_height="76dp" 
       android:layout_centerInParent="true" 
       android:background="@color/white"> 

       <RelativeLayout 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:layout_centerInParent="true"> 

        <ImageView 
         android:id="@+id/btnImageViewForYou" 
         android:layout_width="wrap_content" 
         android:layout_height="wrap_content" 
         android:layout_centerHorizontal="true" 
         android:background="@drawable/icon_for_you" /> 

        <TextView 
         android:id="@+id/btnTextForYou" 
         android:layout_width="wrap_content" 
         android:layout_height="wrap_content" 
         android:layout_below="@+id/btnImageViewForYou" 
         android:layout_centerHorizontal="true" 
         android:layout_marginTop="2dp" 
         android:text="@string/for_you_txt" 
         android:textColor="@color/popular_fragment_four_btn_txt" 
         android:textSize="@dimen/popular_fragment_four_btn_txt_size" /> 
       </RelativeLayout> 


      </RelativeLayout> 
     </RelativeLayout> 

     <RelativeLayout 
      android:layout_width="0dp" 
      android:layout_height="match_parent" 
      android:layout_weight="1"> 

      <RelativeLayout 
       android:id="@+id/shake_deals" 
       android:layout_width="76dp" 
       android:layout_height="76dp" 
       android:layout_centerInParent="true" 
       android:background="@color/white"> 

       <RelativeLayout 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:layout_centerInParent="true"> 

        <ImageView 
         android:id="@+id/btnImageViewShakeDeals" 
         android:layout_width="wrap_content" 
         android:layout_height="wrap_content" 
         android:layout_centerHorizontal="true" 
         android:background="@drawable/icon_shake_deals" /> 

        <TextView 
         android:id="@+id/btnTextShakeDeals" 
         android:layout_width="wrap_content" 
         android:layout_height="wrap_content" 
         android:layout_below="@+id/btnImageViewShakeDeals" 
         android:layout_centerHorizontal="true" 
         android:layout_marginTop="2dp" 
         android:text="@string/shake_deals" 
         android:textColor="@color/popular_fragment_four_btn_txt" 
         android:textSize="@dimen/popular_fragment_four_btn_txt_size" /> 
       </RelativeLayout> 

      </RelativeLayout> 
     </RelativeLayout> 
    </LinearLayout> 

    <android.support.v7.widget.RecyclerView 
     android:id="@+id/recycler_view" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:layout_marginLeft="@dimen/popular_fragment_side_padding" 
     android:layout_marginRight="@dimen/popular_fragment_side_padding" 
     android:layout_marginTop="18dp" 
     android:scrollbars="none" /> 

</LinearLayout> 

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

मेरे ViewPager लेआउट

<?xml version="1.0" encoding="utf-8"?> 
<android.support.design.widget.CoordinatorLayout 
xmlns:android="http://schemas.android.com/apk/res/android" 
xmlns:tools="http://schemas.android.com/tools" 
xmlns:app="http://schemas.android.com/apk/res-auto" 
android:id="@+id/main_content" 
android:layout_width="match_parent" 
android:layout_height="match_parent"> 

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

<android.support.design.widget.AppBarLayout 
    android:id="@+id/appbar" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content"> 

    <android.support.v7.widget.Toolbar 
     android:id="@+id/toolbar" 
     android:layout_width="match_parent" 
     android:layout_height="?attr/actionBarSize" 
     android:layout_gravity="center" 
     android:background="@drawable/toolbar_background" 
     app:layout_scrollFlags="scroll|enterAlways"> 

     <TextView 
      android:id="@+id/toolbar_title" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_gravity="center" 
      android:text="@string/title_home" 
      android:textColor="@color/toolbar_title_txt_color" 
      android:textSize="@dimen/toolbar_txt_size" 
      android:textStyle="bold" /> 

    </android.support.v7.widget.Toolbar> 


    <android.support.design.widget.TabLayout android:id="@+id/tabs" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:background="@color/white" 
     app:tabMode="scrollable" 
     app:tabTextColor="@color/tab_bar_txt" 
     app:tabIndicatorColor="@color/tab_bar_txt_selected" 
     app:tabSelectedTextColor="@color/tab_bar_txt_selected" 
     app:tabTextAppearance="@style/TabTextAppeareance"/> 

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



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

कृपया अपने कोड जोड़ें। –

+0

कोड – Suvro

उत्तर

27

यह ध्यान देने के बारे में एक समस्या है। प्रयास करें:

findViewById(R.id.recycler_view).setFocusable(false); 
findViewById(R.id.temp).requestFocus(); 

<?xml version="1.0" encoding="utf-8"?> 
    <android.support.v4.widget.NestedScrollView 
    android:id="@+id/scrollView" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:background="@color/home_layout_background"> 

    <LinearLayout 
     android:id="@+id/temp" 
     android:focusable="true" 
     android:focusableInTouchMode="true" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:orientation="vertical"> 

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

      <com.daimajia.slider.library.SliderLayout 
       android:id="@+id/image_slider" 
       android:layout_width="match_parent" 
       android:layout_height="@dimen/image_slider_height" 
       android:layout_marginTop="@dimen/image_slider_top_margin" /> 
     </LinearLayout> 

     <LinearLayout 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:layout_marginLeft="@dimen/popular_fragment_side_padding" 
      android:layout_marginRight="@dimen/popular_fragment_side_padding" 
      android:layout_marginTop="@dimen/popular_fragment_side_padding" 
      android:orientation="horizontal" 
      android:weightSum="4"> 

      <RelativeLayout 
       android:layout_width="0dp" 
       android:layout_height="match_parent" 
       android:layout_weight="1"> 

       <RelativeLayout 
        android:id="@+id/free_delivery" 
        android:layout_width="76dp" 
        android:layout_height="76dp" 
        android:layout_centerInParent="true" 
        android:background="@color/white"> 

        <RelativeLayout 
         android:layout_width="wrap_content" 
         android:layout_height="wrap_content" 
         android:layout_centerInParent="true"> 

         <ImageView 
          android:id="@+id/btnImageViewFreeDelivery" 
          android:layout_width="wrap_content" 
          android:layout_height="wrap_content" 
          android:layout_centerHorizontal="true" 
          android:background="@drawable/icon_free_delivery" /> 

         <TextView 
          android:id="@+id/btnTextFreeDelivery" 
          android:layout_width="wrap_content" 
          android:layout_height="wrap_content" 
          android:layout_below="@+id/btnImageViewFreeDelivery" 
          android:layout_centerHorizontal="true" 
          android:layout_marginTop="2dp" 
          android:text="@string/free_delivery_txt" 
          android:textColor="@color/popular_fragment_four_btn_txt" 
          android:textSize="@dimen/popular_fragment_four_btn_txt_size" /> 
        </RelativeLayout> 

       </RelativeLayout> 

      </RelativeLayout> 

      <RelativeLayout 
       android:layout_width="0dp" 
       android:layout_height="match_parent" 
       android:layout_weight="1"> 

       <RelativeLayout 
        android:id="@+id/flash_deals" 
        android:layout_width="76dp" 
        android:layout_height="76dp" 
        android:layout_centerInParent="true" 
        android:background="@color/white"> 


        <RelativeLayout 
         android:layout_width="wrap_content" 
         android:layout_height="wrap_content" 
         android:layout_centerInParent="true"> 

         <ImageView 
          android:id="@+id/btnImageViewFlashDeals" 
          android:layout_width="wrap_content" 
          android:layout_height="wrap_content" 
          android:layout_centerHorizontal="true" 
          android:background="@drawable/icon_flash_deals" /> 

         <TextView 
          android:id="@+id/btnTextFlashDeals" 
          android:layout_width="wrap_content" 
          android:layout_height="wrap_content" 
          android:layout_below="@+id/btnImageViewFlashDeals" 
          android:layout_centerHorizontal="true" 
          android:layout_marginTop="2dp" 
          android:text="@string/flash_deals_txt" 
          android:textColor="@color/popular_fragment_four_btn_txt" 
          android:textSize="@dimen/popular_fragment_four_btn_txt_size" /> 
        </RelativeLayout> 

       </RelativeLayout> 

      </RelativeLayout> 

      <RelativeLayout 
       android:layout_width="0dp" 
       android:layout_height="match_parent" 
       android:layout_weight="1"> 

       <RelativeLayout 
        android:id="@+id/for_you" 
        android:layout_width="76dp" 
        android:layout_height="76dp" 
        android:layout_centerInParent="true" 
        android:background="@color/white"> 

        <RelativeLayout 
         android:layout_width="wrap_content" 
         android:layout_height="wrap_content" 
         android:layout_centerInParent="true"> 

         <ImageView 
          android:id="@+id/btnImageViewForYou" 
          android:layout_width="wrap_content" 
          android:layout_height="wrap_content" 
          android:layout_centerHorizontal="true" 
          android:background="@drawable/icon_for_you" /> 

         <TextView 
          android:id="@+id/btnTextForYou" 
          android:layout_width="wrap_content" 
          android:layout_height="wrap_content" 
          android:layout_below="@+id/btnImageViewForYou" 
          android:layout_centerHorizontal="true" 
          android:layout_marginTop="2dp" 
          android:text="@string/for_you_txt" 
          android:textColor="@color/popular_fragment_four_btn_txt" 
          android:textSize="@dimen/popular_fragment_four_btn_txt_size" /> 
        </RelativeLayout> 


       </RelativeLayout> 
      </RelativeLayout> 

      <RelativeLayout 
       android:layout_width="0dp" 
       android:layout_height="match_parent" 
       android:layout_weight="1"> 

       <RelativeLayout 
        android:id="@+id/shake_deals" 
        android:layout_width="76dp" 
        android:layout_height="76dp" 
        android:layout_centerInParent="true" 
        android:background="@color/white"> 

        <RelativeLayout 
         android:layout_width="wrap_content" 
         android:layout_height="wrap_content" 
         android:layout_centerInParent="true"> 

         <ImageView 
          android:id="@+id/btnImageViewShakeDeals" 
          android:layout_width="wrap_content" 
          android:layout_height="wrap_content" 
          android:layout_centerHorizontal="true" 
          android:background="@drawable/icon_shake_deals" /> 

         <TextView 
          android:id="@+id/btnTextShakeDeals" 
          android:layout_width="wrap_content" 
          android:layout_height="wrap_content" 
          android:layout_below="@+id/btnImageViewShakeDeals" 
          android:layout_centerHorizontal="true" 
          android:layout_marginTop="2dp" 
          android:text="@string/shake_deals" 
          android:textColor="@color/popular_fragment_four_btn_txt" 
          android:textSize="@dimen/popular_fragment_four_btn_txt_size" /> 
        </RelativeLayout> 

       </RelativeLayout> 
      </RelativeLayout> 
     </LinearLayout> 

     <android.support.v7.widget.RecyclerView 
      android:id="@+id/recycler_view" 
      android:focusable="false" 
      android:focusableInTouchMode="false" 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" 
      android:layout_marginLeft="@dimen/popular_fragment_side_padding" 
      android:layout_marginRight="@dimen/popular_fragment_side_padding" 
      android:layout_marginTop="18dp" 
      android:scrollbars="none" /> 

    </LinearLayout> 

    </android.support.v4.widget.NestedScrollView> 
+1

पर यह प्रश्न जोड़ा गया है यह काम करता है। बहुत बहुत धन्यवाद :) – Suvro

+2

हां। वह सही है। बस 'mRecyclerView.setFoucsable (false) जोड़ें; '। और कारण यह है [यहां] (http://stackoverflow.com/a/21235114/1710926) – IndieBoy

+0

इसके लिए धन्यवाद। खोज में काफी समय लगा। मेरे पास एक समान लेआउट है, एक व्यूअर और एक ड्रावरलेआउट के साथ। नेविगेशनड्रावर खोला जब अजीब स्क्रॉल मुद्दा hapenned। अब यह सब ठीक है :) – ruifn

22

मैं एक ही समस्या थी, और मैं इसे निम्नलिखित तरीके से तय की।

रैखिक लेआउट में android:descendantFocusability="blocksDescendants" जोड़ें जो नेस्टेड स्क्रॉल व्यू का एकमात्र बच्चा है।

यह नेस्टेड स्क्रॉल व्यू को न्यूनतम परिवर्तन कोड के साथ शीर्ष से शुरू करने की अनुमति देता है।

+2

यह स्वीकार्य उत्तर होना चाहिए, क्योंकि विचारों की शैली में बदलाव नहीं होता है। जबकि 'एंड्रॉइड: फोकस करने योग्य इंटचोडोड =" सत्य "'दृश्य को देखो जैसे इसे क्लिक किया गया है। – IgniteCoders

+0

मेरे लिए भी काम किया – ymerdrengene

3

बस एक्सएमएल में NestedScrollView के बच्चे को यह पंक्ति जोड़ें:

android:focusableInTouchMode="true" 

समस्या दूर हो जाने!

0

NestedScrollView के बच्चे लेआउट

एंड्रॉयड में इस लाइन जोड़ें: descendantFocusability = "afterDescendants"

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