android - FAB on pre-lollipop devices with the new support lib -
the support library doc states version 22.2 supports floatingactionbutton on pre-lollipop devices.
i have implemented demo app show fab on kitkat. fab shown still can't set elevation neither in xml nor in code. in xml warning , need use tools:ignore="newapi"
. if call setelevation
programmatically exception because method not exist.
i have added layout
<android.support.design.widget.floatingactionbutton android:id="@+id/add_button" style="@style/fab" android:src="@drawable/ic_add_white_24dp" android:contentdescription="@string/add_ringtone" />
where style defined this:
<resources xmlns:tools="http://schemas.android.com/tools"> <style name="fab" tools:ignore="newapi"> <item name="android:layout_width">@dimen/fab_width</item> <item name="android:layout_height">@dimen/fab_height</item> <item name="android:background">@drawable/fab_background</item> <item name="android:layout_alignparentbottom">true</item> <item name="android:layout_alignparentright">true</item> <item name="android:layout_marginbottom">@dimen/fab_margin</item> <item name="android:layout_marginright">@dimen/fab_margin</item> <item name="android:elevation" >@dimen/fab_elevation</item> <item name="android:statelistanimator">@anim/rise</item> </style> </resources>
what should set elevation on kitkat new support library?
since new fab part of support library, you'll need replace
<item name="android:elevation">@dimen/fab_elevation</item>
by
<item name="app:elevation">@dimen/fab_elevation</item>
in style.
Comments
Post a Comment