improved labeled image button padding

This commit is contained in:
Mariotaku Lee 2017-12-29 02:50:32 +08:00
parent d5d5132354
commit 6e71aabc10
No known key found for this signature in database
GPG Key ID: 15C10F89D7C33535
1 changed files with 2 additions and 7 deletions

View File

@ -21,7 +21,6 @@ package org.mariotaku.twidere.view
import android.content.Context
import android.graphics.Canvas
import android.graphics.ColorFilter
import android.graphics.Paint
import android.support.annotation.Dimension
import android.support.v4.view.ViewCompat
@ -99,7 +98,7 @@ class LabeledImageButton(context: Context, attrs: AttributeSet?) : AppCompatImag
} else {
// Draw original image content, but translate it back `text.width / 2f` px.
canvas.save()
canvas.translate(-layout.width / 2f, 0f)
canvas.translate(-layout.width / 2f - drawablePadding, 0f)
super.onDraw(canvas)
canvas.restore()
@ -120,7 +119,7 @@ class LabeledImageButton(context: Context, attrs: AttributeSet?) : AppCompatImag
imageMeasuredHeight = measuredHeight
val layout = textLayout
if (layout != null) {
setMeasuredDimension(imageMeasuredWidth + layout.width + drawablePadding,
setMeasuredDimension(imageMeasuredWidth + layout.width + drawablePadding * 2,
measuredHeight)
}
}
@ -129,10 +128,6 @@ class LabeledImageButton(context: Context, attrs: AttributeSet?) : AppCompatImag
textSize = TypedValue.applyDimension(unit, size, resources.displayMetrics)
}
override fun setColorFilter(cf: ColorFilter?) {
super.setColorFilter(cf)
}
private fun updateLayout() {
val text = this.text
if (text == null) {