TitleBarStyle.java
2.55 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
package com.studymachine.www.other;
import android.content.Context;
import android.graphics.drawable.ColorDrawable;
import android.graphics.drawable.Drawable;
import android.widget.TextView;
import androidx.appcompat.widget.AppCompatTextView;
import androidx.core.content.ContextCompat;
import com.hjq.bar.style.LightBarStyle;
import com.studymachine.www.R;
import com.hjq.widget.view.PressAlphaTextView;
/**
* time : 2021/02/27
* desc : 标题栏初始器
*/
public final class TitleBarStyle extends LightBarStyle {
@Override
public TextView newTitleView(Context context) {
return new AppCompatTextView(context);
}
@Override
public TextView newLeftView(Context context) {
return new PressAlphaTextView(context);
}
@Override
public TextView newRightView(Context context) {
return new PressAlphaTextView(context);
}
@Override
public Drawable getTitleBarBackground(Context context) {
return new ColorDrawable(ContextCompat.getColor(context, R.color.common_primary_color));
}
@Override
public Drawable getBackButtonDrawable(Context context) {
return ContextCompat.getDrawable(context, R.drawable.arrows_left_ic);
}
@Override
public Drawable getLeftTitleBackground(Context context) {
return null;
}
@Override
public Drawable getRightTitleBackground(Context context) {
return null;
}
@Override
public int getChildHorizontalPadding(Context context) {
return (int) context.getResources().getDimension(R.dimen.dp_12);
}
@Override
public int getChildVerticalPadding(Context context) {
return (int) context.getResources().getDimension(R.dimen.dp_14);
}
@Override
public float getTitleSize(Context context) {
return context.getResources().getDimension(R.dimen.sp_15);
}
@Override
public float getLeftTitleSize(Context context) {
return context.getResources().getDimension(R.dimen.sp_13);
}
@Override
public float getRightTitleSize(Context context) {
return context.getResources().getDimension(R.dimen.sp_13);
}
@Override
public int getTitleIconPadding(Context context) {
return (int) context.getResources().getDimension(R.dimen.dp_2);
}
@Override
public int getLeftIconPadding(Context context) {
return (int) context.getResources().getDimension(R.dimen.dp_2);
}
@Override
public int getRightIconPadding(Context context) {
return (int) context.getResources().getDimension(R.dimen.dp_2);
}
}