Tweak UI of UsageProgressBarPreference

- Number in usage summary shows font of size 64.
- Usage summary uses sans font.
- Remove width percentage design.
- Change top/bottom padding from 32 to 16.
- Remove margin between summary text and progress bar.

Bug: 177617478
Test: manual visual
Change-Id: I8e19d98b03226828959be57ed2c0c21a90a88f81
This commit is contained in:
Arc Wang
2021-04-15 21:28:08 +08:00
parent 855f753c80
commit 5ec2095fe7
2 changed files with 10 additions and 14 deletions

View File

@@ -24,29 +24,27 @@
android:orientation="vertical"
android:layout_marginStart="16dp"
android:layout_marginEnd="16dp"
android:paddingTop="32dp"
android:paddingBottom="32dp">
android:paddingTop="16dp"
android:paddingBottom="16dp">
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:id="@+id/usage_summary"
android:layout_width="0dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_constraintWidth_percent="0.45"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintBaseline_toBaselineOf="@id/total_summary"
android:ellipsize="marquee"
android:fontFamily="@*android:string/config_headlineFontFamily"
android:textAppearance="@*android:style/TextAppearance.DeviceDefault.Display1"
android:textAppearance="@*android:style/TextAppearance.DeviceDefault.Body1"
android:textSize="14sp"
android:textAlignment="viewStart"/>
<TextView
android:id="@+id/total_summary"
android:layout_width="0dp"
android:layout_height="wrap_content"
app:layout_constraintWidth_percent="0.45"
app:layout_constraintStart_toEndOf="@id/usage_summary"
app:layout_constraintEnd_toStartOf="@id/custom_content"
android:ellipsize="marquee"
android:textAppearance="@*android:style/TextAppearance.DeviceDefault.Body1"
@@ -54,12 +52,11 @@
android:textAlignment="viewEnd"/>
<FrameLayout
android:id="@+id/custom_content"
android:layout_width="0dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:visibility="gone"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintBottom_toBottomOf="@id/total_summary"
app:layout_constraintWidth_percent="0.1"/>
app:layout_constraintBottom_toBottomOf="@id/total_summary"/>
</androidx.constraintlayout.widget.ConstraintLayout>
<ProgressBar
@@ -67,8 +64,7 @@
style="?android:attr/progressBarStyleHorizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:scaleY="2"
android:layout_marginTop="4dp"
android:scaleY="4"
android:max="100"/>
<TextView

View File

@@ -20,7 +20,7 @@ import android.content.Context;
import android.text.SpannableString;
import android.text.Spanned;
import android.text.TextUtils;
import android.text.style.RelativeSizeSpan;
import android.text.style.AbsoluteSizeSpan;
import android.util.AttributeSet;
import android.view.View;
import android.widget.FrameLayout;
@@ -192,7 +192,7 @@ public class UsageProgressBarPreference extends Preference {
final Matcher matcher = mNumberPattern.matcher(summary);
if (matcher.find()) {
final SpannableString spannableSummary = new SpannableString(summary);
spannableSummary.setSpan(new RelativeSizeSpan(2.4f), matcher.start(),
spannableSummary.setSpan(new AbsoluteSizeSpan(64, true /* dip */), matcher.start(),
matcher.end(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
return spannableSummary;
}