मैं अपनी विस्तार योग्य सूची के लिए एनीमेशन सेट करना चाहता हूं जब सूची ऊपर और नीचे सूची एक अच्छी उपस्थिति दिखाती है और बहुत तेजी से ऊपर और नीचे नहीं होती है।
2 जवाब
अपने बिल्ड में निर्भरता जोड़ें। ग्रेडल
buildscript {
repositories {
jcenter()
}
}
dependencies {
compile 'com.github.aakira:expandable-layout:1.6.0@aar'
}
एक्सएमएल फाइल बनाएं
<com.github.aakira.expandablelayout.ExpandableRelativeLayout
android:id="@+id/expandableLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:ael_expanded="false"
app:ael_duration="500"
app:ael_interpolator="bounce"
app:ael_orientation="vertical">
<TextView
android:id="@+id/text"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="sample" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/text"
android:text="sample2" />
</com.github.aakira.expandablelayout.ExpandableRelativeLayout>
जावा कोड जोड़ें
ExpandableLinearLayout expandableLayout
= (ExpandableLinearLayout) findViewById(R.id.expandableLayout);
child.setText("Sets text from a server");
expandableLayout.initLayout(); // Recalculate size of children
// recycler view
// you must set a ViewHolder#setIsRecyclable(false) and ExpandableLinearLayout#setInRecyclerView(true)
@Override
public void onBindViewHolder(final ViewHolder holder, final int position) {
holder.setIsRecyclable(false);
holder.expandableLinearLayout.setInRecyclerView(true);
}
अपने बच्चे को देखने के लिए बस इस विधि का प्रयोग करें।
private void animateView(final View target, final int type) {
Animation anim = new ExpandCollapseAnimation(target,type);
anim.setDuration(getAnimationDuration());
anim.setAnimationListener(new AnimationListener() {
@Override
public void onAnimationStart(Animation animation) {}
@Override
public void onAnimationRepeat(Animation animation) {}
@Override
public void onAnimationEnd(Animation animation) {
if (type == ExpandCollapseAnimation.EXPAND) {
if (parent instanceof ListView) {
ListView listView = (ListView) parent;
int movement = target.getBottom();
Rect r = new Rect();
boolean visible = target.getGlobalVisibleRect(r);
Rect r2 = new Rect();
listView.getGlobalVisibleRect(r2);
if (!visible) {
listView.smoothScrollBy(movement, getAnimationDuration());
} else {
if (r2.bottom == r.bottom) {
listView.smoothScrollBy(movement,getAnimationDuration());
}
}
}
}
}
});
target.startAnimation(anim);
}
संबंधित सवाल
नए सवाल
android
एंड्रॉइड Google का मोबाइल ऑपरेटिंग सिस्टम है, जिसका उपयोग प्रोग्रामिंग या डिजिटल डिवाइस (स्मार्टफोन, टैबलेट, ऑटोमोबाइल्स, टीवी, वियर, ग्लास, IoT) को विकसित करने के लिए किया जाता है। एंड्रॉइड से संबंधित विषयों के लिए, एंड्रॉइड-विशिष्ट टैग जैसे कि एंड्रॉइड-इरादे, एंड्रॉइड-गतिविधि, एंड्रॉइड-एडॉप्टर आदि का उपयोग करें। विकास या प्रोग्रामिंग के अलावा अन्य प्रश्नों के लिए, लेकिन एंड्रॉइड फ्रेमवर्क से संबंधित हैं, इस लिंक का उपयोग करें: https: // android.stackexchange.com।