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