这个添加一个button的点击特效
是在博客上看到的 这只是转载 上效果图
public class AnimRelativeLayout extends RelativeLayout {
private boolean superb = false;
private int pivot = 1;
private AnimClickUtil bamAnim;
public AnimRelativeLayout(Context context) {
this(context,null);
this.setClickable(true);
}
public AnimRelativeLayout(Context context, AttributeSet attrs) {
this(context, attrs,0);
this.setClickable(true);
}
public AnimRelativeLayout(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
this.setClickable(true);
initView();
}
private void initView() {
bamAnim = new AnimClickUtil();
}
public void openSuperb(boolean isOpen) {
superb = isOpen;
}
@Override
@SuppressLint("ClickableViewAccessibility")
public boolean onTouchEvent(MotionEvent event) {
switch (event.getAction()) {
case MotionEvent.ACTION_DOWN:
pivot = bamAnim.startAnimDown(this, superb, event.getX(), event.getY());
break;
case MotionEvent.ACTION_CANCEL:
bamAnim.startAnimUp(this, pivot,false);
break;
case MotionEvent.ACTION_UP:
bamAnim.startAnimUp(this, pivot,true);
break;
default:
break;
}
return super.onTouchEvent(event);
}
public void setDownEndListener(AnimClickUtil.OnAnimEndListener listener) {
bamAnim.setAnimEndListener(listener);
}
}
具体使用 这里展示可以不用复制
<com.abroad.zqyears_java.view.home.view.AnimRelativeLayout
android:id="@+id/activity_subscription_content_month"
android:layout_width="match_parent"
android:layout_height="70dp"
android:layout_below="@+id/activity_subscription_content_year"
android:layout_marginLeft="30dp"
android:layout_marginTop="20dp"
android:layout_marginRight="30dp"
android:background="@drawable/subscription_button_bg_select_no"
android:descendantFocusability="blocksDescendants"
android:padding="2dp">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/subscription_button_bg2">
<TextView
android:id="@+id/activity_subscription_content_month_text1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_marginTop="11dp"
android:text="@string/解锁所有功能month"
android:textColor="@color/subscription_year_text1_color"
android:textSize="12sp" />
<TextView
android:id="@+id/month_price_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/activity_subscription_content_month_text1"
android:layout_centerHorizontal="true"
android:layout_marginTop="5dp"
android:text="@string/a24月无限修复"
android:textColor="@color/subscription_year_text1_color"
android:textSize="18sp"
android:textStyle="bold" />
</RelativeLayout>
</com.abroad.zqyears_java.view.home.view.AnimRelativeLayout>
包裹住你想展示的内容就好 转载原文链接找不到了
|