82 lines
2.9 KiB
Java
82 lines
2.9 KiB
Java
|
|
|
||
|
|
package com.pukka.jiecheng.utils;
|
||
|
|
|
||
|
|
import android.content.Context;
|
||
|
|
import android.view.View;
|
||
|
|
import android.widget.TextView;
|
||
|
|
|
||
|
|
import androidx.constraintlayout.widget.ConstraintLayout;
|
||
|
|
import androidx.core.view.ViewCompat;
|
||
|
|
|
||
|
|
import com.pukka.jiecheng.R;
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Author: wxf
|
||
|
|
* Date: 2023/1/12 10:48
|
||
|
|
* Description:Top样式切换
|
||
|
|
*/
|
||
|
|
public class TopStyleUtils {
|
||
|
|
// 搜索、历史、订购、帮助 样式切换
|
||
|
|
public static void topStyleChange(Context context, View view, boolean focus) {
|
||
|
|
// ConstraintLayout constraintLayout = (ConstraintLayout) view;
|
||
|
|
// View icon = constraintLayout.getChildAt(0);
|
||
|
|
// icon.setSelected(focus);
|
||
|
|
// TextView textView = (TextView) constraintLayout.getChildAt(1);
|
||
|
|
if (focus) {
|
||
|
|
view.animate().scaleX(1.1f).scaleY(1.1f).setDuration(100).start();
|
||
|
|
// textView.setTextColor(context.getResources().getColor(R.color.index_top_text_focus));
|
||
|
|
// textView.getPaint().setFakeBoldText(true);
|
||
|
|
} else {
|
||
|
|
view.animate().scaleX(1.0f).scaleY(1.0f).setDuration(100).start();
|
||
|
|
// textView.setTextColor(context.getResources().getColor(R.color.index_top_text_nor));
|
||
|
|
// textView.getPaint().setFakeBoldText(false);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
public static void topImageChange(View view, boolean focus) {
|
||
|
|
if (focus) {
|
||
|
|
ViewCompat.animate(view).scaleX(1.05f).scaleY(1.05f).setDuration(100).start();
|
||
|
|
} else {
|
||
|
|
ViewCompat.animate(view).scaleX(1.0f).scaleY(1.0f).setDuration(100).start();
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
public static void topImageChangeFilter(View view, boolean focus) {
|
||
|
|
if (focus) {
|
||
|
|
ViewCompat.animate(view).scaleX(1.02f).scaleY(1.02f).setDuration(100).start();
|
||
|
|
} else {
|
||
|
|
ViewCompat.animate(view).scaleX(1.0f).scaleY(1.0f).setDuration(100).start();
|
||
|
|
}
|
||
|
|
}
|
||
|
|
/**
|
||
|
|
* 一行的大模板 放大 防止焦点框外溢
|
||
|
|
* */
|
||
|
|
public static void topImageChange3(View view, boolean focus) {
|
||
|
|
if (focus) {
|
||
|
|
ViewCompat.animate(view).scaleX(1.02f).scaleY(1.05f).setDuration(100).start();
|
||
|
|
} else {
|
||
|
|
ViewCompat.animate(view).scaleX(1.0f).scaleY(1.0f).setDuration(100).start();
|
||
|
|
}
|
||
|
|
}
|
||
|
|
/**
|
||
|
|
* 对view放大1.05f
|
||
|
|
*
|
||
|
|
* @param view view
|
||
|
|
* @param focus focus
|
||
|
|
*/
|
||
|
|
public static void topImageChange2(View view, boolean focus) {
|
||
|
|
if (focus) {
|
||
|
|
ViewCompat.animate(view).scaleX(1.03f).scaleY(1.05f).setDuration(100).start();
|
||
|
|
} else {
|
||
|
|
ViewCompat.animate(view).scaleX(1.0f).scaleY(1.0f).setDuration(100).start();
|
||
|
|
}
|
||
|
|
}
|
||
|
|
public static void topImageChange4(View view, boolean focus) {
|
||
|
|
if (focus) {
|
||
|
|
ViewCompat.animate(view).scaleX(1.03f).scaleY(1.03f).setDuration(100).start();
|
||
|
|
} else {
|
||
|
|
ViewCompat.animate(view).scaleX(1.0f).scaleY(1.0f).setDuration(100).start();
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|