Skip to content

Commit 1bfd188

Browse files
committed
对外公开setter、getter方法
1 parent 65fac40 commit 1bfd188

1 file changed

Lines changed: 64 additions & 2 deletions

File tree

library/src/main/java/com/foolchen/lib/multiitemtextview/MultiItemTextView.kt

Lines changed: 64 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,10 +104,72 @@ open class MultiItemTextView : View {
104104
invalidate()
105105
}
106106

107-
fun getTextSize(): Float {
108-
return mTextSize
107+
fun getTextSize() = mTextSize
108+
109+
/** 设置item宽度 */
110+
fun setItemWidth(width: Float) {
111+
mItemWidth = width
112+
requestLayout()
113+
invalidate()
114+
}
115+
116+
fun getItemWidth() = mItemWidth
117+
118+
fun setItemHeight(height: Float) {
119+
mItemHeight = height
120+
requestLayout()
121+
invalidate()
122+
}
123+
124+
fun getItemHeight() = mItemHeight
125+
126+
fun setRefWidth(width: Float) {
127+
mRefWidth = width
128+
requestLayout()
129+
invalidate()
130+
}
131+
132+
fun setDividerColor(color: Int) {
133+
mDividerColor = color
134+
invalidate()
135+
}
136+
137+
fun getDividerColor() = mDividerColor
138+
139+
fun setDivideWidth(width: Float) {
140+
mDividerWidth = width
141+
requestLayout()
142+
invalidate()
109143
}
110144

145+
fun setDividerEnable(start: Boolean, top: Boolean, end: Boolean, bottom: Boolean,
146+
middle: Boolean) {
147+
mStartDividerEnable = start
148+
mTopDividerEnable = top
149+
mEndDividerEnable = end
150+
mBottomDividerEnable = bottom
151+
mMiddleDividerEnable = middle
152+
requestLayout()
153+
invalidate()
154+
}
155+
156+
fun setGravity(gravity: Int) {
157+
mGravity = gravity
158+
invalidate()
159+
}
160+
161+
fun getGravity() = mGravity
162+
163+
fun setItemPadding(start: Int, top: Int, end: Int, bottom: Int) {
164+
mItemPadding[0] = start
165+
mItemPadding[1] = top
166+
mItemPadding[2] = end
167+
mItemPadding[3] = bottom
168+
requestLayout()
169+
invalidate()
170+
}
171+
172+
111173
private fun init(context: Context?, attrs: AttributeSet?) {
112174
if (context != null && attrs != null) {
113175
val ta = context.obtainStyledAttributes(attrs, R.styleable.MultiItemTextView)

0 commit comments

Comments
 (0)