improved labeled image button padding
This commit is contained in:
parent
d5d5132354
commit
6e71aabc10
|
@ -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) {
|
||||
|
|
Loading…
Reference in New Issue