| | |
| | | |
| | | import android.content.Context; |
| | | import android.content.res.ColorStateList; |
| | | import android.graphics.Typeface; |
| | | import android.graphics.drawable.ColorDrawable; |
| | | import android.graphics.drawable.Drawable; |
| | | import android.util.TypedValue; |
| | | import android.widget.TextView; |
| | | |
| | | import androidx.appcompat.content.res.AppCompatResources; |
| | | |
| | | import com.android.app_base.utils.ScreenSizeUtils; |
| | | import com.application.zhangshi_app_android.R; |
| | | import com.hjq.bar.style.CommonBarStyle; |
| | | |
| | |
| | | * @desc TitleBar统一样式 |
| | | */ |
| | | public class MyTitleBarStyle extends CommonBarStyle { |
| | | |
| | | @Override |
| | | public TextView createLeftView(Context context) { |
| | | return super.createLeftView(context); |
| | | public Typeface getTitleTypeface(Context context, int style) { |
| | | return Typeface.createFromAsset(context.getAssets(), "roboto_regular.ttf"); |
| | | } |
| | | |
| | | @Override |
| | | public Typeface getLeftTitleTypeface(Context context, int style) { |
| | | return Typeface.createFromAsset(context.getAssets(), "roboto_regular.ttf"); |
| | | } |
| | | |
| | | @Override |
| | | public Typeface getRightTitleTypeface(Context context, int style) { |
| | | return Typeface.createFromAsset(context.getAssets(), "roboto_regular.ttf"); |
| | | } |
| | | |
| | | @Override |
| | | public Drawable getTitleBarBackground(Context context) { |
| | | return new ColorDrawable(context.getColor(R.color.color_title_bar_background)); |
| | | //根据当前主题获取不同的背景颜色 |
| | | TypedValue typedValue = new TypedValue(); |
| | | context.getTheme().resolveAttribute(R.attr.titleBarBackgroundColor, typedValue, true); |
| | | return new ColorDrawable(typedValue.data); |
| | | } |
| | | |
| | | @Override |
| | |
| | | return (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 16, context.getResources().getDisplayMetrics()); |
| | | } |
| | | |
| | | |
| | | |
| | | } |