1

Ich möchte Floating-Aktion-Schaltfläche oben auf Kartenfragment platzieren. Mein Kartenfragment ist vollständig den gesamten Bildschirm ausgefüllt. Wenn ich lege eine schwebende Aktionstaste wird nicht auf der Karte Fragment kommenden Bitte beachten Sie das Bild angehängt:Floating-Aktion-Schaltfläche oben auf Kartenfragment

map fragment with search bar

Bitte hier Layout-Code finden

<?xml version="1.0" encoding="utf-8"?> 

<ScrollView xmlns:app="http://schemas.android.com/apk/res-auto" 
    xmlns:tools="http://schemas.android.com/tools" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    android:fillViewport="true"> 
    <LinearLayout 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 

     android:orientation="vertical" 
     android:weightSum="1"> 


     <android.support.v7.widget.CardView 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:layout_marginTop="@dimen/margin_small" 
      > 

      <fragment 
       android:id="@+id/autocomplete_fragment" 
       android:name="com.google.android.gms.location.places.ui.PlaceAutocompleteFragment" 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" 
       /> 
      <!--<ImageView 
       android:layout_width="wrap_content" 
       android:layout_height="match_parent" 
       android:src="@drawable/bell32" 
       android:visibility="invisible" 
       /> 
      <android.support.v7.widget.SwitchCompat 
       android:layout_width="wrap_content" 
       android:layout_height="match_parent" 
       android:id="@+id/alarm_on_switch" 
       android:layout_gravity="right|top" 
       android:layout_marginRight="@dimen/margin_small" 
       android:drawableLeft="@drawable/bell32" 
       />--> 

     </android.support.v7.widget.CardView> 
     <fragment xmlns:android="http://schemas.android.com/apk/res/android" 
      xmlns:tools="http://schemas.android.com/tools" 
      android:id="@+id/map" 
      android:name="com.google.android.gms.maps.SupportMapFragment" 
      android:layout_width="match_parent" 
      tools:context="reminder.locrem.com.locationreminder.MapsActivity" 
      android:layout_height="match_parent" /> 

     <android.support.design.widget.FloatingActionButton 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_gravity="top|right" 
      android:layout_margin="16dp" 
      android:src="@drawable/done" 
      app:layout_anchorGravity="bottom|right|end" 
      app:elevation="4dp" /> 

    </LinearLayout> 

</ScrollView> 
+0

posten Sie Ihre XML-Code –

+0

ich die Frage bearbeitet haben xml-Code – sasikanth

Antwort

3

Sie können FrameLayout verwenden, um acieve, was Sie wollen.

<?xml version="1.0" encoding="utf-8"?> 
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:app="http://schemas.android.com/apk/res-auto" 
    xmlns:tools="http://schemas.android.com/tools" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:fillViewport="true"> 
    <LinearLayout 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:orientation="vertical" 
     android:weightSum="1"> 
     <android.support.v7.widget.CardView 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:layout_marginTop="@dimen/margin_small"> 
      <fragment 
       android:id="@+id/autocomplete_fragment" 
       android:name="com.google.android.gms.location.places.ui.PlaceAutocompleteFragment" 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content"/> 

     </android.support.v7.widget.CardView> 
     <FrameLayout 
      android:layout_width="match_parent" 
      android:layout_height="match_parent"> 
      <fragment 
       android:id="@+id/map" 
       android:name="com.google.android.gms.maps.SupportMapFragment" 
       android:layout_width="match_parent" 
       android:layout_height="match_parent" 
       tools:context="reminder.locrem.com.locationreminder.MapsActivity" /> 

      <android.support.design.widget.FloatingActionButton 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:layout_gravity="top|right" 
       android:layout_margin="16dp" 
       android:src="@drawable/done" 
       app:elevation="4dp" 
       app:layout_anchorGravity="bottom|right|end" /> 
     </FrameLayout> 

    </LinearLayout> 
</ScrollView> 
+0

Vielen Dank für Ihre Hilfe – sasikanth

+0

@sasikanth freundlicherweise upvote, wenn dies Ihr Problem löst. –

1

Hallo Sie versuchen, diese können Code ..

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

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


<android.support.design.widget.FloatingActionButton 
    android:id="@+id/imageButton" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_alignParentBottom="true" 
    android:layout_alignParentEnd="true" 
    android:layout_alignParentRight="true" 
    android:layout_margin="30dp" 
    android:background="@android:color/transparent" 
    android:clickable="true" 
    android:onClick="myLocationCall" 
    android:rotation="0" /> 

    </RelativeLayout> 
+0

Hallo sasikanth hinzufügen, wenn diese Sie dann ACCEPT bitte helfen und upvote this..thanks –

+0

Hallo Dank für Ihren Vorschlag, aber es half nicht, dass ich gepostet mein Layout XML-Code auch bitte lassen Sie mich wissen, wenn es irgendwelche Fehler in diesem – sasikanth

0

Sie müssen nur die android ändern: layout_gravity = "top | ri ght“

<android.support.design.widget.CoordinatorLayout 
    android:id="@+id/main_content" 
    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"> 

      <com.google.android.gms.maps.MapView 
      android:id="@+id/mapView" 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" 
      /> 

      <android.support.design.widget.FloatingActionButton 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:layout_gravity="top|right" 
       android:layout_margin="16dp" 
       android:src="@drawable/ic_done" 
       app:layout_anchor="@id/lvToDoList" 
       app:layout_anchorGravity="bottom|right|end" /> 
</android.support.design.widget.CoordinatorLayout> 
Verwandte Themen