michael
michael

Reputation: 3955

Android: Set material design elevation for button using AppCompat V7

When following this Android tutorial using AppCompat V7 to get the new Tool Bar work, the android.support.v7.widget.Toolbar supports android:elevation on SDK's < Lollipop. This is because they use android.support.v7.widget.Toolbar and not Toolbar.

Is there equivalent for button? Something like android.support.v7.widget.Button? (This one not exist) Or any other workaround in the kind of overlaying the Button in some view supporting elevation? (I don't want implementation of creating custom shapes with gradients for look & feel of elevation).

Thanks,

Upvotes: 1

Views: 1631

Answers (2)

Amar
Amar

Reputation: 141

You can use the Floating Action Button from support design library .

Use below code to the layout where you want this button.

<android.support.design.widget.FloatingActionButton
                android:id="@+id/fab"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:src="@mipmap/ic_fab"
                android:layout_gravity="bottom|end"
                app:backgroundTint="#0091b4"
                app:elevation="6dp"
                app:pressedTranslationZ="12dp"
                android:layout_margin="10dp"
                android:scaleType="centerCrop" />

Do add design dependency in your project Add below in the dependency list of build.gradle file

compile 'com.android.support:design:23.0.1'

Upvotes: 1

Sergey Shevchenko
Sergey Shevchenko

Reputation: 56

Unfortunately you will have to do what you do not want. Because there is no support button view yet. (As i know :) perhaps some omniscient person will correct my answer)

Upvotes: 1

Related Questions