1

Im Versuch geworfen werden, um eine Floating Action-Taste zwischen 2 Widget/Layout

im 99% sicher, dass ich bereits dieses Tutorial zum Erstellen und arbeitete How can I add the new "Floating Action Button" between two widgets/layouts

Aber jetzt, wenn Ich versuche, dies wieder zu tun Ich habe diesen Fehler

Exception raised during rendering: android.widget.LinearLayout$LayoutParams cannot be cast to android.support.design.widget.CoordinatorLayout$LayoutParams 

Sie wissen nicht, wie Sie es beheben? Und wie erstellt man eine Ansicht wie diese enter image description here

+0

Chack Ihre Bindung Sie verwendet 'Linear' anstelle von' Koordinator' oder umgekehrt – sushildlh

Antwort

0

i verwalten diese Fehler so zu beheben:

<LinearLayout 
xmlns:android="http://schemas.android.com/apk/res/android" 
xmlns:app="http://schemas.android.com/apk/res-auto" 
android:orientation="vertical" 
android:layout_width="match_parent" 
android:layout_height="match_parent"> 

<android.support.design.widget.CoordinatorLayout 
    android:layout_width="match_parent" 
    android:layout_height="match_parent"> 

     <LinearLayout 

      android:id="@+id/anchor" 
      android:orientation="vertical" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:gravity="top" 
      android:background="@color/colorPrimary"> 


       <TextView 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:layout_marginTop="40dp" 
        android:text="@string/Homepage" 
        android:textSize="18sp" 
        android:textColor="@color/white" 
        android:id="@+id/place" 
        android:layout_gravity="center_horizontal" 
        android:gravity="top"/> 

       <TextView 
        android:id="@+id/fullName" 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:layout_marginTop="15dp" 
        android:layout_marginBottom="15dp" 
        android:textColor="@color/white" 
        android:textSize="25sp" 
        android:layout_gravity="center_horizontal" /> 

     </LinearLayout> 
     <android.support.design.widget.FloatingActionButton 
      android:id="@+id/fab" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_margin="16dp" 
      android:clickable="true" 
      android:src="@drawable/ic_admin" 
      app:fabSize="mini" 
      app:layout_anchor="@id/anchor" 
      app:layout_anchorGravity="bottom|right|end"/> 

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

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

        <android.support.v7.widget.RecyclerView 
         android:id="@+id/List" 
         android:layout_width="match_parent" 
         android:layout_height="wrap_content" 
         android:scrollbars="vertical" 
         android:layout_weight="1"/> 

        <Button 
         android:id="@+id/btnlogout" 
         android:layout_width="match_parent" 
         android:layout_height="wrap_content" 
         android:text="@string/btn_logout" 
         android:background="@color/red"/> 
     </LinearLayout> 

Mein Linearlayout Einwickeln das coordinatorLayout anstelle des Coordinators als rootview.

4

Ich habe ein ähnliches Problem seit der Verwendung von Android-Support-Design-Lib 24.2.0, mit 24.1.1 funktioniert alles gut.

Update:Here ist die entsprechende Frage im Android Open Source Project - Issue Tracker

+0

Version 24.2.1 behebt nun das Problem [Link] (https://code.google.com/p/android/issues/detail? id = 220250 # c32) –

Verwandte Themen