2013-08-28 9 views
7

यह एंड्रॉइड समकक्ष this आईओएस प्रश्न है।एंड्रॉइड - ScrollView नक्शे के साथ चौकोर की तरह + सूची

एक दृश्य बनाने की कोशिश कर रहा है जिसमें स्क्रीन के लगभग 20% (एक्शनबार के तहत ...) पर नक्शा दृश्य शामिल है और शेष स्क्रीन एक स्क्रॉलव्यू है जो स्क्रॉल करते समय, MapView और छिपे हुए शीर्ष पर ओवरलैप करता है यह। फोरस्क्वेयर के एंड्रॉइड ऐप की तरह संक्षेप में। कोई विचार?

+0

[http://stackoverflow.com/questions/25487861/android-maps-markers-bounds-at-the-center-of-top-half-of-map-area](http://stackoverflow.com/प्रश्न/25487861/एंड्रॉइड-मैप्स-मार्कर-बाउंड-ऑन-द-सेंटर-टॉप-ऑफ-मैप-एरिया) –

उत्तर

0

तुम सिर्फ अपने xml में घोषणा कर सकते हैं दायर एक ScrollView कि एक LinearLayout एम्बेड करता है, कि एम्बेड करता है एक MapView:

<ScrollView xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:layout_gravity="center_horizontal" 
    android:fillViewport="true" > 

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

     <fragment 
      android:id="@+id/map" 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" 
      class="com.google.android.gms.maps.MapFragment" /> 

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

     ...... Your list and other stuff ....... 

     </LinearLayout> 
    </LinearLayout> 
</ScrollView> 

तो फिर तुम layout_weight विशेषता

निर्दिष्ट करके प्रत्येक तत्व के लिए आकार सेट कर सकते संपादित करें इवानदान डो, हमारी चर्चा के बाद मुझे यह लिंक मिला जो आप चाहते हैं जो कर सकता है (यकीन नहीं है कि, मैंने इसे आजमाया नहीं है): Android: Have an arbitrary View slide under another View like the software keyboard does

+0

ने कोशिश की, 'मैपफ्रैगमेंट' 'लेआउट_वेट' = 1 और 'लीनियरलाउट' 'layout_weight' = 3 लेकिन मैं जो कुछ देखता हूं वह मेरी पूरी स्क्रीन पर और नीचे कहीं भी एक सूची का संकेत है ... और यह मेरे मानचित्र के शीर्ष पर भी स्क्रॉल नहीं करता है। – OferM

+0

यह अजीब बात है, मेरे पास मेरे ऐप में बहुत अधिक कोड है। यदि आप मानचित्र को 'छवि दृश्य' के साथ प्रतिस्थापित करते हैं, तो क्या यह स्क्रॉल करता है? साथ ही, क्या आप पहले 'LinearLayout' से 4' में 'weightSum' विशेषता निर्दिष्ट करने का प्रयास कर सकते हैं? – jbihan

+0

ठीक है, इसलिए इसे 'छवि दृश्य' में बदल दिया और मुझे एहसास हुआ कि मेरी सूची बस इतना बड़ी नहीं थी, इसलिए कोई स्क्रॉलिंग की आवश्यकता नहीं थी। (मूक)। लेकिन अब जब मैं स्क्रॉल करता हूं, तो 'इमेज व्यू'/'मैप' बस रोल हो जाता है, मैं चाहता हूं कि यह शीर्ष पर चिपके रहें क्योंकि सूची आखिरकार ओवरलैप की तरह स्क्रॉल हो जाएगी और इसे पूरी तरह छुपाएगी। मैं उस प्रभाव को कैसे प्राप्त करूं? – OferM

4

अंतिम अद्यतन

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
xmlns:tools="http://schemas.android.com/tools" 
xmlns:map="http://schemas.android.com/apk/res-auto" 
android:layout_width="match_parent" 
android:layout_height="match_parent" 
tools:context=".MainActivity" > 

<fragment 
    android:id="@+id/map_fragment" 
    android:name="com.myapp.MapFragment" 
    android:layout_width="match_parent" 
    android:layout_height="fill_parent" /> 

<fragment 
    android:id="@id/list_fragment" 
    android:name="com.myapp.ListFragment" 
    android:layout_width="wrap_content" 
    android:layout_height="fill_parent" /> 

तो मैं एक अदृश्य हैडर सूची में तो जैसे जोड़ें:

@Override 
public View onCreateView(final LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { 
    super.onCreateView(inflater, container, savedInstanceState); 

    View view = inflater.inflate(R.layout.listview, container, false); 
    SwipeListView listView = (SwipeListView) view.findViewById(R.id.venue_list); 

    // An invisible view added as a header to the list and clicking it leads to the mapfragment 
    TextView invisibleView = new TextView(inflater.getContext()); 
    invisibleView.setBackgroundColor(Color.TRANSPARENT); 
    invisibleView.setHeight(300); 
    invisibleView.setOnClickListener(new OnClickListener() { 
     @Override 
     public void onClick(View v) { 
      listener.moveToMapFragment(); 
                     } 
    }); 
    listView.addHeaderView(invisibleView); 

यह शायद ही आदर्श है, लेकिन यह काम करता है। मुझे आशा है कि यह किसी की मदद करेगा ..

+1

: यदि आपको बेहतर समाधान मिला है तो कृपया मुझे बताएं – user965071

+0

यह अभी तक का सबसे अच्छा समाधान है जो मैंने पाया है। मैंने अदृश्य फ्रेम पर एक क्लिक हैंडलर जोड़ा है जो पूरे स्क्रीन को फिट करने के लिए मानचित्र खोलता है। – OferM

+0

क्या आप अपने द्वारा बनाए गए लेआउट को साझा कर सकते हैं? – user965071

1

सबसे आसान समाधान अपने स्लाइडर सामग्री (SlidingUpPanel का दूसरा पैरामीटर) के लिए एक मार्जिन जोड़ने के लिए और फिर fading पृष्ठभूमि को दूर है। सभी एक्सएमएल से किया।

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