The sub-View automatically moves Layout according to the rule, and the view moves layout
Project address: https://github.com/xxxzhi/ChildAutoMovi-Layout
Previously, I saw a page that was flashing and moving. At that time, I came up with an idea. Can I make such a selection interface?
The implementation is actually relatively simple. After writing it, I feel that I can make a View that can be reused well and easily expand the mobile rule. At ordinary times, we simply implemented it and roughly wrote several mobile rules.
ChildAutoMoviLayout implements the parent class
Given that RelativeLayout is easier to use, ChildAutoMoviLayout is used as a subclass of RelativeLayout. In this way, when you use this Layout,
It can be expanded more conveniently. For example, use Margins.
Add a subview
In addition, because each sub-View can be consistent, because automatic movement basically involves some similar forms of View movement. So I use the Adapter of Android AbsListView as ChildAutoMoviLayout.
. ChildAutoMoviLayout adds a subview to the Adapter by reading the Adapter. ChildAutoMoviLayout does not use addView to add a View. In this way, you only need to implement one
Adapter. You can even use the ListView Adapter directly.
Mobile rule
For a mobile rule, I design an interface. You only need to implement that interface and give it to ChildAutoMoviLayout. SetMoviInterface. Two methods are used for moving rules.
/*** Move ** @ param view * @ param height move height * @ param width move width */void move (View view, int width, int height ); /*** initialization position ** @ param view * @ param height move height * @ param width move width */void init (View view, int width, int height );
Animation implementation
I use TimeTask as a timer, and then use the timer to move a middle-class tag (subclass view) every 20 milliseconds)
timer.scheduleAtFixedRate(timerTask, 1000, 20);
Introduction
### Xml usage:
<com.houzhi.childautomovi.view.ChildAutoMoviLayout android:id="@+id/tagView" android:layout_below="@+id/tag_container" android:layout_width="match_parent" android:layout_height="match_parent"> </com.houzhi.childautomovi.view.ChildAutoMoviLayout>
Java code example:
Project address: https://github.com/xxxzhi/ChildAutoMovi-Layout