【发布时间】:2021-02-26 21:48:04
【问题描述】:
当我点击recyclerview 元素时,我需要制作一个类似于下拉列表的动画。在项目 2 xml 标记中,1 是主要的,第二个在单击时变为可见。按照思路,应该是这样的:我点击了元素,它打开了一个dropout动画。再次按下时,它关闭了。还有动画。此刻,元素只是骤然出现,又骤然消失。如果有这种可能性,我不想使用第三方库。我想做类似this
holder.itemView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (!flag) {
Intent intent = new Intent(mContext, MessageActivity.class);
intent.putExtra("userid", user.getId());
mContext.startActivity(intent);
} else if(holder.info.getVisibility()==View.GONE) {
holder.info.setVisibility(View.VISIBLE);
} else {
holder.info.setVisibility(View.GONE);
}
}
);
在这部分代码中,我要么打开消息活动,要么打开有关用户的其他信息。
布局:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:padding="10dp"
android:layout_height="wrap_content">
<androidx.cardview.widget.CardView
android:layout_width="match_parent"
android:layout_height="wrap_content">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/info_about">
///Info about users(username and him photo)
</RelativeLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/info_about"
android:paddingTop="5dp"
android:layout_marginTop="45dp"
android:layout_centerHorizontal="true"
android:orientation="vertical"
android:visibility="gone"
android:id="@+id/info">
///Info about users(call_number, email... When i clicked on item)
</LinearLayout>
</androidx.cardview.widget.CardView>
</LinearLayout>
【问题讨论】:
标签: android android-recyclerview android-animation