2016-07-25 10 views
8

के अंदर कार्डव्यू नीचे सीमा काट दिया गया है, मैं स्क्रॉलव्यू के अंदर कार्डव्यू डाल रहा हूं, हम नीचे देखने की उम्मीद करते हैं कि सीमा को दिखाया जाना चाहिए (नीचे चित्र देखें)। लेकिन ऐसा नहीं है। समस्या यह है कि मैं कार्डव्यू की सीमा देखने के लिए नीचे स्क्रॉल नहीं कर सकता।स्क्रॉलव्यू एंड्रॉइड

SO पर सभी समाधान लेआउट_मार्गिन को पैडिंग में बदलना है, लेकिन अगर हम सीमा दिखाना चाहते हैं तो कार्डव्यू के मामले में यह नहीं है। मैंने मूल रूप से सब कुछ करने की कोशिश की। लेकिन अभी भी काम नहीं करता है। scroll to bottom cannot see the border

चित्र 1. नीचे करने के लिए स्क्रॉल सीमा

नहीं देख सकते हैं

we can see the top border

चित्र 2. हम देख सकते हैं शीर्ष सीमा

निम्न XML कोड

<LinearLayout 
xmlns:android="http://schemas.android.com/apk/res/android" 
xmlns:custom="http://schemas.android.com/apk/res-auto" 
android:layout_width="match_parent" 
android:layout_height="match_parent" 
android:orientation="vertical" 
> 
    <ScrollView 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:fillViewport="true"> 

      <android.support.v7.widget.CardView 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" 
       android:layout_margin="8dp"> 
        <LinearLayout 
         android:layout_width="match_parent" 
         android:layout_height="wrap_content" 
         android:orientation="vertical" 
         > 
        ... 
        </LinearLayout> 
      </CardView> 
    </LinearLayout> 

संदर्भ है : ScrollView doesn't scroll to the bottom

ScrollView cuts off the top and leaves space at the bottom

I can't show LinearLayout at bottom to scroll view

Android ScrollView refuses to scroll to bottom

+1

आप एक स्क्रीनशॉट मदद करने के लिए बेहतर समझने में हमारी क्या चल रहा है संलग्न कर सकते हैं? – Vucko

+0

@ वोको स्क्रीन शॉट जोड़ा गया, धन्यवाद – Cheng

उत्तर

4

एक समाधान मैं सिर्फ पाया एक LinearLayout या RelativeLayout साथ CardView लपेट और उसके गद्दी स्थापित करने के लिए है। उदाहरण के लिए, यदि आप कार्डव्यू में कुछ ड्रॉप छाया प्रभाव चाहते हैं, तो 8 डीपी कहें, आप अपने लाइनरलाइट या रिलेटिव लेआउट के 4 डीपी पैडिंग और कार्डव्यू के 4 डीपी लेआउट_मार्गिन सेट कर सकते हैं।

<ScrollView 
    android:id="@+id/item_scrollview" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:scrollbars="none" 
    tools:visibility="visible"> 

    <LinearLayout 
     android:id="@+id/item_wrapper_layout" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:layout_margin="@dimen/content_margin" 
     android:paddingBottom="32dp" 
     android:orientation="vertical"> 

     <android.support.v7.widget.CardView 
      android:id="@+id/item_cardview" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      card_view:cardBackgroundColor="@color/colorPrimary" 
      card_view:cardCornerRadius="4dp" 
      card_view:cardUseCompatPadding="true"> 

आसपास LinearLayout आवरण जोड़ना:

+0

हाँ, लेकिन अतिरिक्त परत जोड़ने से व्यूअर पेड़ को पार करने के लिए अतिरिक्त समय लगेगा, जिसे अनुकूलित नहीं किया गया है। खैर, अगर आपको प्रदर्शन की परवाह नहीं है, तो इसे – Cheng

+0

पर काम करना चाहिए, मुझे पैडिंग भी सेट नहीं करना पड़ा था। बस रैखिक लेआउट जोड़ा गया और यह समस्या हल हो गई –

9

मैं एक ही समस्या में पड़ गए और निम्न करना था (कुंजी cardview जहाँ मैं paddingBottom जोड़ा आसपास LinearLayout आवरण है) कार्डव्यू मेरे लिए क्या काम करता है।

यह भी ध्यान दें, मुझे कार्ड_व्यू जोड़ना था: कार्डयूसे कॉम्पेट पैडिंग = "सत्य" सीमा रेखा को सही दिखने के लिए कार्डव्यू पर।

यहां अंतिम परिणाम है जहां लाल बॉक्स दिखाता है कि कार्डव्यू का विस्तार और स्क्रॉल होने पर पैडिंग को जोड़ा गया है।

screenshot

+0

मैं कार्डव्यू को लपेटने के लिए एक अतिरिक्त परत जोड़ने का बड़ा प्रशंसक नहीं हूं, दृश्य दृश्य पेड़ को पार करने में अतिरिक्त समय लगेगा, विशेष रूप से सत्य जब गहरा होता है। यदि आपको प्रदर्शन की परवाह नहीं है, तो उसे – Cheng

+0

काम करना चाहिए एक रैपर के रूप में एक लीनियरलाउट जोड़ना इस डिजाइन पर भारी प्रदर्शन वृद्धि नहीं करेगा। यदि यह सब एक RecyclerView में निहित था, तो मैं देख सकता था कि यह एक मुद्दा हो सकता है। इस तरह का एक दृश्य गहराई से नहीं होना चाहिए - कार्ड के ऊपर esp। –

+0

यदि आप उपरोक्त स्क्रीन शॉट देखते हैं तो स्पष्ट रूप से एक मार्जिन या पैडिंग समस्या है। स्क्रॉलबार को अब तक स्क्रॉल नहीं किया जा सकता है भले ही यह नीचे तक पहुंच जाए। तो इस पैडिंग/मार्जिन मुद्दे को ठीक करना सही तरीका है। एक लाइनरलेआउट को सिर्फ एक हैक रास्ता, या आईएमएचओ लपेटना, यह संयोग से काम करता है। – Cheng

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