2016-07-31 9 views
0

Entschuldigung im Voraus, wenn diese Frage bereits irgendwo auf dieser Website gefragt wurde. Ich war mir nicht sicher, wie ich es in der Suchleiste schreiben sollte. Ich habe es trotzdem versucht.Android: Layer-Liste Floating-Aktion Button - Schaltfläche Schatten sieht anders aus, nachdem App pausiert und fortgesetzt

Also im Grunde weiß ich Android Studio können Sie eine schwimmende Aktion Schaltfläche ohne den zusätzlichen Aufwand jetzt erstellen, aber ich sehe nur, wenn ich es ohne es machen kann. Ich habe es mit etwas Hilfe getan, was ich von einer anderen Frage hier bekam aber aus irgendeinem Grund, wenn ich die App starten, die Floating Action-Taste Schatten sieht wie folgt aus:

enter image description here

Aber wenn ich verlassen und vor es wird aus dem Speicher entfernt werden (entweder Verlassen und wenige Sekunden später oder Anhalten der App und die Wiederaufnahme der Rückkehr), schaltet sich der Schatten in dieses:

enter image description here

das ist mein circle.xml Datei:

<?xml version="1.0" encoding="utf-8"?> 
<layer-list xmlns:android="http://schemas.android.com/apk/res/android"> 

<item android:top="8px"> 
    <layer-list> 
     <item> 
      <shape android:shape="oval"> 
       <solid android:color="#08000000"/> 
       <padding 
        android:bottom="3px" 
        android:left="3px" 
        android:right="3px" 
        android:top="3px" 
        /> 
      </shape> 
     </item> 
     <item> 
      <shape android:shape="oval"> 
       <solid android:color="#09000000"/> 
       <padding 
        android:bottom="2px" 
        android:left="2px" 
        android:right="2px" 
        android:top="2px" 
        /> 
      </shape> 
     </item> 
     <item> 
      <shape android:shape="oval"> 
       <solid android:color="#10000000"/> 
       <padding 
        android:bottom="2px" 
        android:left="2px" 
        android:right="2px" 
        android:top="2px" 
        /> 
      </shape> 
     </item> 
     <item> 
      <shape android:shape="oval"> 
       <solid android:color="#11000000"/> 
       <padding 
        android:bottom="1px" 
        android:left="1px" 
        android:right="1px" 
        android:top="1px" 
        /> 
      </shape> 
     </item> 
     <item> 
      <shape android:shape="oval"> 
       <solid android:color="#12000000"/> 
       <padding 
        android:bottom="1px" 
        android:left="1px" 
        android:right="1px" 
        android:top="1px" 
        /> 
      </shape> 
     </item> 
     <item> 
      <shape android:shape="oval"> 
       <solid android:color="#13000000"/> 
       <padding 
        android:bottom="1px" 
        android:left="1px" 
        android:right="1px" 
        android:top="1px" 
        /> 
      </shape> 
     </item> 
     <item> 
      <shape android:shape="oval"> 
       <solid android:color="#14000000"/> 
       <padding 
        android:bottom="1px" 
        android:left="1px" 
        android:right="1px" 
        android:top="1px" 
        /> 
      </shape> 
     </item> 
     <item> 
      <shape android:shape="oval"> 
       <solid android:color="#15000000"/> 
       <padding 
        android:bottom="1px" 
        android:left="1px" 
        android:right="1px" 
        android:top="1px" 
        /> 
      </shape> 
     </item> 

    </layer-list> 
</item> 

<item > 
    <shape android:shape="oval"> 
     <solid android:color="#FFBB00" /> 
    </shape> 
</item> 


</layer-list> 

Und das ist, wie mein activity_main.xml:

<?xml version="1.0" encoding="utf-8"?> 
<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" 
    android:paddingBottom="@dimen/activity_vertical_margin" 
    android:paddingLeft="@dimen/activity_horizontal_margin" 
    android:paddingRight="@dimen/activity_horizontal_margin" 
    android:paddingTop="@dimen/activity_vertical_margin" 
    tools:context="com.myname.testapp.MainActivity"> 


    <ImageButton 
     android:layout_margin="15dp" 
     android:layout_width="70dp" 
     android:layout_height="70dp" 
     android:background="@drawable/circle" 
     android:id="@+id/fab_button" 
     android:layout_alignParentBottom="true" 
     android:layout_centerHorizontal="true" /> 

    <ListView 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:id="@+id/ResultsListView" 
     android:layout_alignParentTop="true" 
     android:layout_alignParentLeft="true" 
     android:layout_alignParentStart="true" /> 

</RelativeLayout> 

Jede Idee, was los ist? Ich bin noch relativ neu in der Entwicklung von Android-Apps, wenn es sich um einen kleinen Fehler handelt. Ich bin mir immer noch nicht sicher, was los ist. Jede Hilfe wird sehr geschätzt. Vielen Dank.

Antwort

1

Änderung Ihrer circle.xml dazu:

<?xml version="1.0" encoding="utf-8"?> 
<layer-list xmlns:android="http://schemas.android.com/apk/res/android"> 
    <item > 
     <shape android:shape="oval"> 
      <solid android:color="#FFBB00" /> 
     </shape> 
    </item> 
</layer-list> 

und fügen Sie diese Zeile

android: Höhe = "5dp"

zum Bildknopf.

mehr Infos Defining Shadows and Clipping Views

Verwandte Themen