2
我試圖向我的回收商視圖添加一些點擊動畫as shown here,但未成功。這是我的一些代碼。Recycler視圖點擊動畫
裏面我的活動
@Override
protected void onCreate(Bundle savedInstanceState) {
...
mRecyclerView = (RecyclerView) findViewById(R.id.recycler_view);
ItemOffsetDecoration itemDecoration = new ItemOffsetDecoration(this, R.dimen.card_item_offset);
mRecyclerView.addItemDecoration(itemDecoration);
mLayoutManager = new LinearLayoutManager(this);
mRecyclerView.setLayoutManager(mLayoutManager);
mAdapter = new CustomAdapter(this);
mRecyclerView.setAdapter(mAdapter);
}
裏面我ViewHolder
public CustomViewHolder(View itemView) {
super(itemView);
this.itemView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
/* on click stuff here */
}
});
}
裏面我CardView.xml
<?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.CardView
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:card_view="http://schemas.android.com/apk/res-auto"
android:id="@+id/card_loading"
android:layout_width="match_parent"
android:layout_height="wrap_content"
card_view:cardCornerRadius="4dp"
android:clickable="true"
android:background="?android:attr/selectableItemBackground">
<TextView
android:id="@+id/card_message"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</android.support.v7.widget.CardView>
不知道問題出在哪裏,但預先感謝您的幫助=)
很高興爲您效勞:) –