File tree Expand file tree Collapse file tree 2 files changed +8
-4
lines changed
core/src/main/java/com/alamkanak/weekview Expand file tree Collapse file tree 2 files changed +8
-4
lines changed Original file line number Diff line number Diff line change @@ -6,6 +6,7 @@ import android.graphics.Paint
6
6
import android.graphics.Rect
7
7
import android.graphics.RectF
8
8
import android.graphics.drawable.Drawable
9
+ import android.text.Layout
9
10
import android.text.StaticLayout
10
11
import android.text.TextPaint
11
12
import android.util.SparseArray
@@ -127,7 +128,8 @@ private class HeaderUpdater(
127
128
date.isWeekend -> viewState.weekendHeaderTextPaint
128
129
else -> viewState.headerTextPaint
129
130
}
130
- return dayLabel.toTextLayout(textPaint = textPaint, width = viewState.dayWidth.toInt())
131
+ val alignment = if (viewState.isLtr) Layout .Alignment .ALIGN_NORMAL else Layout .Alignment .ALIGN_CENTER
132
+ return dayLabel.toTextLayout(textPaint = textPaint, width = viewState.dayWidth.toInt(), alignment = alignment)
131
133
}
132
134
133
135
private fun <E > SparseArray<E>.hasKey (key : Int ): Boolean = indexOfKey(key) >= 0
Original file line number Diff line number Diff line change @@ -103,16 +103,18 @@ internal class ViewState(var isLtr: Boolean = true) {
103
103
textAlign = if (isLtr) Paint .Align .RIGHT else Paint .Align .LEFT
104
104
}
105
105
106
+ private val headerTextAlign = if (isLtr) Paint .Align .CENTER else Paint .Align .RIGHT
107
+
106
108
val headerTextPaint = TextPaint (Paint .ANTI_ALIAS_FLAG ).apply {
107
- textAlign = Paint . Align . CENTER
109
+ textAlign = headerTextAlign
108
110
}
109
111
110
112
val todayHeaderTextPaint = TextPaint (Paint .ANTI_ALIAS_FLAG ).apply {
111
- textAlign = Paint . Align . CENTER
113
+ textAlign = headerTextAlign
112
114
}
113
115
114
116
val weekendHeaderTextPaint = TextPaint (Paint .ANTI_ALIAS_FLAG ).apply {
115
- textAlign = Paint . Align . CENTER
117
+ textAlign = headerTextAlign
116
118
}
117
119
118
120
val headerBottomLinePaint = Paint ()
You can’t perform that action at this time.
0 commit comments