Skip to content

Commit f2dcf9e

Browse files
committed
https://github.com/mylhyl/Android-CircleDialog/issues/29
1 parent 2efcb1c commit f2dcf9e

File tree

5 files changed

+62
-19
lines changed

5 files changed

+62
-19
lines changed

app/src/main/java/com/mylhyl/circledialog/sample/MainActivity.java

+4-3
Original file line numberDiff line numberDiff line change
@@ -98,14 +98,15 @@ public void onItemClick(BaseQuickAdapter adapter, View view, int position) {
9898
.setCanceledOnTouchOutside(false)
9999
.setCancelable(false)
100100
.configDialog(params -> {
101-
params.backgroundColor = Color.DKGRAY;
102-
params.backgroundColorPress = Color.BLUE;
101+
// params.backgroundColor = Color.DKGRAY;
102+
// params.backgroundColorPress = Color.BLUE;
103103
})
104104
.setTitle("标题")
105+
.setSubTitle("副标题")
105106
.setText("冷却风扇口无异物,风机扇叶无损伤,无过热痕迹")
106107
.configText(params -> {
107108
// params.gravity = Gravity.LEFT | Gravity.TOP;
108-
params.padding = new int[]{100, 0, 100, 50};
109+
// params.padding = new int[]{100, 0, 100, 50};
109110
})
110111
.setNegative("取消", null)
111112
.setPositive("确定", v ->

circledialog/src/main/java/com/mylhyl/circledialog/params/TitleParams.java

+5-1
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,14 @@ public TitleParams[] newArray(int size) {
2929
* 标题
3030
*/
3131
public String text;
32+
/**
33+
* 内间距 [left, top, right, bottom]
34+
*/
35+
public int[] padding = CircleDimen.TITLE_PADDING;
3236
/**
3337
* 标题高度
3438
*/
35-
public int height = CircleDimen.TITLE_HEIGHT;
39+
public int height = 0;
3640
/**
3741
* 标题字体大小
3842
*/

circledialog/src/main/java/com/mylhyl/circledialog/res/values/CircleDimen.java

+42-14
Original file line numberDiff line numberDiff line change
@@ -4,116 +4,144 @@
44
* Created by hupei on 2017/3/29.
55
*/
66
public class CircleDimen {
7+
78
/**
89
* 对话框圆角
910
*/
1011
public static int DIALOG_RADIUS = 18;
12+
1113
/**
12-
* 标题高
14+
* 标题文字内间距
1315
*/
14-
public static int TITLE_HEIGHT = 100;
15-
/**
16-
* 文本对话框的内容高度
17-
*/
18-
public static int TEXT_HEIGHT = 105;
16+
public static int[] TITLE_PADDING = {29, 29, 29, 0};
17+
1918
/**
2019
* 标题字体大小
2120
*/
2221
public static int TITLE_TEXT_SIZE = 16;
22+
2323
/**
2424
* 副标题字体大小
2525
*/
2626
public static int SUBTITLE_TEXT_SIZE = 14;
27+
28+
/**
29+
* 副标题文字内间距
30+
*/
31+
public static int[] SUBTITLE_PADDING = {29, 29, 29, 0};
32+
33+
/**
34+
* 文本对话框的内间距
35+
*/
36+
public static int[] TEXT_PADDING = {29, 29, 29, 29};
37+
38+
/**
39+
* 文本对话框的内容高度
40+
*/
41+
public static int TEXT_HEIGHT = 105;
42+
2743
/**
2844
* 文字消息字体大小
2945
*/
3046
public static int CONTENT_TEXT_SIZE = 16;
47+
3148
/**
3249
* 列表item字体大小
3350
*/
3451
public static int ITEM_CONTENT_TEXT_SIZE = 16;
52+
3553
/**
3654
* 列表每行高度
3755
*/
3856
public static int ITEM_HEIGHT = 120;
57+
3958
/**
4059
* 列表文字内间距
4160
*/
4261
public static int[] ITEM_TEXT_PADDING = {12, 0, 12, 0};
62+
4363
/**
4464
* 输入框的文体大小
4565
*/
4666
public static int INPUT_TEXT_SIZE = 15;
67+
4768
/**
4869
* 底部按钮高度
4970
*/
5071
public static int FOOTER_BUTTON_HEIGHT = 120;
72+
5173
/**
5274
* 底部按钮字体大小
5375
*/
5476
public static int FOOTER_BUTTON_TEXT_SIZE = 16;
77+
5578
/**
5679
* 列表模式底部按钮与列表的距离
5780
*/
5881
public static int BUTTON_ITEMS_MARGIN = 15;
82+
5983
/**
6084
* 输入框的高
6185
*/
6286
public static int INPUT_HEIGHT = 200;
87+
6388
/**
6489
* 水平进度条高度
6590
*/
6691
public static int PROGRESS_HEIGHT_HORIZONTAL = 10;
92+
6793
/**
6894
* 转换进度条高度
6995
*/
7096
public static int PROGRESS_HEIGHT_SPINNER = 47;
7197
public static int[] PROGRESS_MARGINS = {12, 26, 12, 26};
7298
public static int[] PROGRESS_TEXT_PADDING = {0, 0, 0, 26};
99+
73100
/**
74101
* 输入框的边距
75102
*/
76103
public static int[] INPUT_MARGINS = {29, 12, 29, 24};
104+
77105
/**
78106
* 输入框的内间距
79107
*/
80108
public static int[] INPUT_PADDING = {12, 12, 12, 12};
109+
81110
/**
82111
* 输入框计数器的边距
83112
*/
84113
public static int[] INPUT_COUNTER_MARGINS = {6, 6};
114+
85115
/**
86116
* 输入框计数器的字体大小
87117
*/
88118
public static int INPUT_COUNTER__TEXT_SIZE = 12;
119+
89120
/**
90121
* lottie动画下文字的边距
91122
*/
92123
public static int[] LOTTIE_TEXT_MARGINS = {0, 35, 0, 18};
124+
93125
/**
94126
* lottie动画的高度
95127
*/
96128
public static int LOTTIE_HEIGHT = 159;
129+
97130
/**
98131
* lottie动画宽度
99132
*/
100133
public static int LOTTIE_WIDTH = 159;
134+
101135
/**
102136
* 加载框文字大小
103137
*/
104138
public static int LOADING_TEXT_SIZE = 15;
105-
/**
106-
* 文本对话框的内间距
107-
*/
108-
public static int[] TEXT_PADDING = {29, 29, 29, 29};
109-
/**
110-
* 副标题文字内间距
111-
*/
112-
public static int[] SUBTITLE_PADDING = {29, 0, 29, 0};
139+
113140
/**
114141
* 对话框透明度,范围:0-1;1不透明
115142
*/
116143
public static float DIALOG_ALPHA = 1f;
144+
117145
/**
118146
* 对话框宽度,范围:0-1;1整屏宽
119147
*/

circledialog/src/main/java/com/mylhyl/circledialog/view/BodyInputView.java

+6
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
import com.mylhyl.circledialog.params.DialogParams;
1717
import com.mylhyl.circledialog.params.InputParams;
1818
import com.mylhyl.circledialog.res.drawable.InputDrawable;
19+
import com.mylhyl.circledialog.res.values.CircleDimen;
1920
import com.mylhyl.circledialog.view.listener.InputView;
2021
import com.mylhyl.circledialog.view.listener.OnCreateInputListener;
2122

@@ -35,6 +36,11 @@ public BodyInputView(Context context, CircleParams params) {
3536
}
3637

3738
private void init(Context context, CircleParams params) {
39+
int rlPaddingTop = params.titleParams == null ? params.subTitleParams == null
40+
? CircleDimen.TITLE_PADDING[1] : params.subTitleParams.padding[1]
41+
: params.titleParams.padding[1];
42+
setPadding(0, rlPaddingTop, 0, 0);
43+
3844
DialogParams dialogParams = params.dialogParams;
3945
final InputParams inputParams = params.inputParams;
4046

circledialog/src/main/java/com/mylhyl/circledialog/view/TitleView.java

+5-1
Original file line numberDiff line numberDiff line change
@@ -91,10 +91,14 @@ private TextView createTitle(TitleParams titleParams) {
9191
RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT);
9292
layoutParamsTitle.addRule(RelativeLayout.CENTER_HORIZONTAL);
9393
tvTitle.setLayoutParams(layoutParamsTitle);
94-
tvTitle.setHeight(titleParams.height);
94+
if (titleParams.height != 0)
95+
tvTitle.setHeight(titleParams.height);
9596
tvTitle.setTextColor(titleParams.textColor);
9697
tvTitle.setTextSize(titleParams.textSize);
9798
tvTitle.setText(titleParams.text);
99+
int[] padding = titleParams.padding;
100+
if (padding != null)
101+
tvTitle.setPadding(padding[0], padding[1], padding[2], padding[3]);
98102
tvTitle.setTypeface(tvTitle.getTypeface(), titleParams.styleText);
99103
mTitleLayout.addView(tvTitle);
100104
addView(mTitleLayout);

0 commit comments

Comments
 (0)