This repository was archived by the owner on Sep 3, 2023. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +10
-9
lines changed
core/src/main/java/com/afollestad/materialdialogs Expand file tree Collapse file tree 2 files changed +10
-9
lines changed Original file line number Diff line number Diff line change @@ -28,8 +28,8 @@ import android.widget.TextView
28
28
import androidx.annotation.RestrictTo
29
29
import androidx.annotation.RestrictTo.Scope.LIBRARY_GROUP
30
30
import com.afollestad.materialdialogs.R
31
+ import com.afollestad.materialdialogs.utils.MDUtil.additionalPaddingForFont
31
32
import com.afollestad.materialdialogs.utils.MDUtil.dimenPx
32
- import com.afollestad.materialdialogs.utils.MDUtil.maybeSetAdditionalPadding
33
33
import com.afollestad.materialdialogs.utils.isNotVisible
34
34
import com.afollestad.materialdialogs.utils.isRtl
35
35
import com.afollestad.materialdialogs.utils.isVisible
@@ -92,10 +92,7 @@ class DialogTitleLayout(
92
92
val requiredHeight = iconViewHeight.coerceAtLeast(titleView.measuredHeight)
93
93
val actualHeight = requiredHeight + frameMarginVertical + titleMarginBottom
94
94
95
- setMeasuredDimension(
96
- parentWidth,
97
- actualHeight
98
- )
95
+ setMeasuredDimension(parentWidth, actualHeight)
99
96
}
100
97
101
98
override fun onLayout (
@@ -114,8 +111,8 @@ class DialogTitleLayout(
114
111
115
112
val titleHalfHeight = titleView.measuredHeight / 2
116
113
val titleTop = contentMidPoint - titleHalfHeight
117
- val titleBottom = contentMidPoint + titleHalfHeight
118
- + titleView.maybeSetAdditionalPadding(titleView.measuredHeight )
114
+ val titleBottom = contentMidPoint + titleHalfHeight +
115
+ titleView.additionalPaddingForFont( )
119
116
var titleLeft: Int
120
117
var titleRight: Int
121
118
Original file line number Diff line number Diff line change @@ -234,10 +234,14 @@ object MDUtil {
234
234
}
235
235
}
236
236
237
- @RestrictTo(LIBRARY_GROUP ) fun TextView.maybeSetAdditionalPadding (height : Int ): Int {
237
+ /* *
238
+ * See [https://github.com/afollestad/material-dialogs/issues/1936]. Calculates additional
239
+ * spacing required to prevent a given [TextView] from being cut off at the bottom.
240
+ */
241
+ @RestrictTo(LIBRARY_GROUP ) fun TextView.additionalPaddingForFont (): Int {
238
242
val fm = paint.fontMetrics
239
243
val textHeight = fm.descent - fm.ascent
240
- return if (textHeight > height ) (textHeight - height ).toInt() else 0
244
+ return if (textHeight > measuredHeight ) (textHeight - measuredHeight ).toInt() else 0
241
245
}
242
246
243
247
@RestrictTo(LIBRARY_GROUP ) inline fun Int?.ifNotZero (block : (value: Int ) -> Unit ) {
You can’t perform that action at this time.
0 commit comments