2016-02-12 4 views
8

Ich versuche, das Google Maps-Layout zu imitieren. Es scheint, dass sie ein Koordinatorlayout mit einem Kartenfragment verwenden. Die Probleme sind:Google Maps und Koordinator Layout

1 - Ich kann einen Mindestwert der Ansicht von unten nicht einstellen (siehe Bild 1 und 3).

2 - Ich brauche einen maximimum von kollabiert, ich einen Teil der Karte immer zeigen wollen (Bild 2)

3 - Wenn ich die Karte zu viel kollabieren, die FAB und Karte disapears.

Google maps picture 1 Google maps picture 2 My app picture 3 My app picture 4 My app picture 5

Der Code:

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

     <android.support.design.widget.CollapsingToolbarLayout 
      android:id="@+id/collapsing_toolbar_layout" 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" 
      android:fitsSystemWindows="true" 
      app:contentScrim="?attr/colorPrimary" 
      app:layout_scrollFlags="scroll|exitUntilCollapsed"> 

      <fragment 
       android:id="@+id/map" 
       android:name="com.google.android.gms.maps.SupportMapFragment" 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" 
       app:layout_collapseMode="parallax" 
       app:layout_scrollFlags="scroll|enterAlways" /> 

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

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

    <android.support.v4.widget.NestedScrollView 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     app:layout_behavior="@string/appbar_scrolling_view_behavior"> 

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

    <android.support.design.widget.FloatingActionButton 
     android:id="@+id/fab_camera" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_alignParentBottom="true" 
     android:layout_alignParentRight="true" 
     android:layout_margin="@dimen/activity_horizontal_margin" 
     android:clickable="true" 
     android:src="@drawable/ic_photo_camera_white" 
     app:backgroundTint="@color/colorPrimary" 
     app:fabSize="normal" 
     app:layout_anchor="@+id/appbar" 
     app:layout_anchorGravity="bottom|right|end" /> 
</android.support.design.widget.CoordinatorLayout> 

Antwort

1

Für Screenshot num 3 als min Höhe Sie so etwas tun könnte:

Verwenden Sie für Screenshot 5 eine leere Symbolleiste, um die Mindesthöhe festzulegen.

einen Blick auf die nächste Probe nehmen:

<android.support.design.widget.CoordinatorLayout 
xmlns:android="http://schemas.android.com/apk/res/android" 
xmlns:app="http://schemas.android.com/apk/res-auto" 
android:layout_width="match_parent" 
android:layout_height="match_parent" 
android:fitsSystemWindows="true"> 

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

    <android.support.design.widget.CollapsingToolbarLayout 
     android:id="@+id/collapse_toolbar" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     app:layout_scrollFlags="scroll|exitUntilCollapsed" 
     android:fitsSystemWindows="true"> 

     <fragment 
      android:id="@+id/map" 
      android:name="com.google.android.gms.maps.MapFragment" 
      android:layout_width="match_parent" 
      android:layout_height="300dp" 
      android:fitsSystemWindows="true" 
      app:layout_collapseMode="parallax" 
      app:layout_scrollFlags="scroll|enterAlways" /> 

     <android.support.v7.widget.Toolbar 
      android:id="@+id/toolbar" 
      android:layout_width="match_parent" 
      android:layout_height="?attr/actionBarSize" 
      app:layout_collapseMode="pin"/> 

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

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

<android.support.v4.widget.NestedScrollView 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:layout_gravity="fill_vertical" 
    app:layout_behavior="@string/appbar_scrolling_view_behavior"> 

    <FrameLayout 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:id="@+id/fragment_container"> 

    </FrameLayout> 

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

<android.support.design.widget.FloatingActionButton 
    android:id="@+id/fab" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_marginTop="-60dp" 
    android:layout_marginRight="16dp" 
    android:src="@android:drawable/ic_dialog_email" 
    app:layout_anchor="@id/appBar" 
    app:layout_anchorGravity="bottom|right|end" /> 

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

Könnten Sie bitte eine Beispielimplementierung geben? – Madhan