Implementation method of floating actionbutton developed by Android

1、 Introduction

This class inherits from ImageView, so we can use all the properties of ImageView for this control

2、 Use preparation in as build Write in the grade file

3、 Instructions for use

In the XML file, notice the blue font

You can see that we use the app attribute, so we need to add this attribute to the root container.

Attribute introduction:

1. App: borderwidth = "" ------------------ border width, usually set to 0, is used to solve Android 5 The shadow on X device cannot be displayed normally

2. App: backgroundtint = "" ------------------ the background color of the button is not set. The color of coloraccent in theme is used by default

3. App: ripplecolor = "" ------------------ click the edge shadow color

4. App: elevation = "" ------------------ width of edge shadow

5. App: pressedtranslationz = "16dp" --- when clicking a button, the width of the button edge shadow is usually set to be greater than the value of elevation

In addition, we want to click one color of the button and one color of the normal state to improve the user experience, so we create the file floatbutton in the drawable folder xml

Then we can set the background of the floatactionbutton to this drawable file, and the app: backgroundtint = "" property can no longer be set

design sketch:

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>