AnimationWrapLayout is an Android library used to create a layout which aligns child views dynamically (with a animation) on a new line.
- Add
AnimationWrapLayout
widget to your layout.
<com.github.sjnyag.animationwraplayout.AnimationWrapLayout
android:id="@+id/list"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:padding="8dp"
animation_wrap_layout:each_margin_height="4dp"
animation_wrap_layout:each_margin_width="4dp" />
- Call
addViewWithAnimation(View view, int position)
orremoveViewWithAnimation(View view)
instead ofaddView
orremoveView
to feel the same way as ViewGroup.
AnimationWrapLayout layout = (AnimationWrapLayout) findViewById(R.id.list);
findViewById(R.id.button1).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
layout.addViewWithAnimation(yourView, anyPosition);
}
});
findViewById(R.id.button2).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
layout.removeViewWithAnimation(yourView)
}
});
your build.gradle
allprojects {
repositories {
...
maven { url 'https://jitpack.io' }
}
}
dependencies {
compile 'com.github.sjnyag:AnimationWrapLayout:0.2.0'
}
Copyright 2017 sjnyag
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.