我想添加一些点击动画如下所示我回收的看法,但没有成功.这是我的一些代码.
在我的活动中
@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);
}
Run Code Online (Sandbox Code Playgroud)
在我的ViewHolder中
public CustomViewHolder(View itemView) {
super(itemView);
this.itemView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
/* on click stuff here */
}
});
}
Run Code Online (Sandbox Code Playgroud)
在我的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>
Run Code Online (Sandbox Code Playgroud)
不确定问题出在哪里,但提前感谢您帮助=)
android ripple material-design android-cardview android-recyclerview
Wiki仅指:shadowColor(color)、shadowOffset(object)、shadowOpacity(number) 和shadowRadius(number)。可以使用传播半径或者不支持此属性?
body {
width: 100vw;
height: 100vh;
display: flex;
align-items: center;
justify-content: center;
}
div {
width: 200px;
height: 200px;
box-shadow: 0 0 0 20px rgba(0, 0, 0, 0.2);
}Run Code Online (Sandbox Code Playgroud)
<div/>Run Code Online (Sandbox Code Playgroud)