Usage analysis of drag bar and scoring component developed by Android

This article describes the use of drag bar and scoring component developed by Android. Share with you for your reference, as follows:

Today, I took out my android book and went on to study. Android has many components and sometimes gets confused. This time, the drag bar and scoring components are introduced. These two components are also super simple

Let's study one by one.

1. Dragging the bar is similar to adjusting the volume on an Android phone. The difference between this component and the dialog box is that the user can operate it. The XML representation of this component is as follows

This light is too boring. Here I make a small example of dragging and switching pictures. Here we will introduce the length of the drag bar. This length is controllable. For example, I have 5 pictures here. The size of the drag bar is 5. I wrote this setting directly in the program. The implementation is very simple, that is, add an ImageView on the basis of the drag bar, and then drag the drag bar. If the listening value changes, just switch the ImageView. The following is the main code.

The effect picture is shown below. I think it's still very good.

2. The following is the scoring plug-in. Android is a five pointed star by default. If necessary, it can be made into something else

I've got a custom type here. Let's have a look

(1) Get an XML file under drawable. The content is as follows

star_ Empty is a gray pentagram, star_ Full is a yellow five pointed star. The above configuration file is also very simple to understand. Let's embed this style into the scoring component. First, write a style file

Incidentally, starconfig is the configuration file above and the tag below. The common attributes of this component are step size and the number of stars, as shown below

Naturally, the following is event handling

Let's see the effect

More readers interested in Android related content can view the topics on this site: summary of Android basic component usage, introduction and advanced tutorial of Android development, summary of Android layout skills, summary of Android view skills, summary of activity operation skills of Android programming, summary of Android resource operation skills, and Android control usage summary

I hope this article will help you in Android programming.

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
分享
二维码
< <上一篇
下一篇>>