Skip to content

Commit cb34987

Browse files
committed
Customize preference choice dialogs style
1 parent 3e3e685 commit cb34987

9 files changed

Lines changed: 91 additions & 5 deletions
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
<selector xmlns:android="http://schemas.android.com/apk/res/android">
2+
<item android:color="?attr/colorOnPrimaryContainer" android:state_checked="true" />
3+
<item android:color="?attr/colorOnSurface" />
4+
</selector>
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
<selector xmlns:android="http://schemas.android.com/apk/res/android">
2+
<item android:drawable="@drawable/single_choice_background_on" android:state_checked="true" />
3+
<item android:drawable="@drawable/single_choice_background_off" />
4+
</selector>
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<ripple xmlns:android="http://schemas.android.com/apk/res/android"
2+
android:color="?android:colorControlHighlight">
3+
<item>
4+
<inset
5+
android:insetLeft="24dp"
6+
android:insetTop="1dp"
7+
android:insetRight="24dp"
8+
android:insetBottom="1dp">
9+
<shape android:shape="rectangle">
10+
<solid android:color="@android:color/transparent" />
11+
<corners android:radius="16dp" />
12+
</shape>
13+
</inset>
14+
</item>
15+
</ripple>
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<ripple xmlns:android="http://schemas.android.com/apk/res/android"
2+
android:color="?android:colorControlHighlight">
3+
<item>
4+
<inset
5+
android:insetLeft="24dp"
6+
android:insetTop="1dp"
7+
android:insetRight="24dp"
8+
android:insetBottom="1dp">
9+
<shape android:shape="rectangle">
10+
<solid android:color="?attr/colorPrimaryContainer" />
11+
<corners android:radius="16dp" />
12+
</shape>
13+
</inset>
14+
</item>
15+
</ripple>

app/src/main/res/layout-land/assistant_setup_dialog.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
android:layout_height="wrap_content"
4141
android:layout_marginTop="16dp"
4242
app:cardBackgroundColor="?attr/colorSurfaceContainerHigh"
43-
app:cardCornerRadius="20dp"
43+
app:cardCornerRadius="16dp"
4444
app:layout_constraintEnd_toEndOf="parent"
4545
app:layout_constraintStart_toStartOf="parent"
4646
app:layout_constraintTop_toBottomOf="@id/dialog_title">
@@ -51,7 +51,7 @@
5151
android:layout_width="match_parent"
5252
android:layout_height="wrap_content"
5353
android:maxLines="8"
54-
android:padding="16dp"
54+
android:padding="12dp"
5555
tools:text="@string/digital_assistant_setup_message" />
5656
</com.google.android.material.card.MaterialCardView>
5757

app/src/main/res/layout/activity_main.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
app:expandedTitleMarginEnd="24dp"
2424
app:expandedTitleMarginStart="24dp"
2525
app:expandedTitleMarginTop="96dp"
26-
app:expandedTitleTextAppearance="?attr/textAppearanceHeadlineLargeEmphasized"
26+
app:expandedTitleTextAppearance="?attr/textAppearanceDisplaySmallEmphasized"
2727
app:expandedTitleTextColor="?attr/colorOnSurface"
2828
app:layout_scrollFlags="scroll|exitUntilCollapsed|snap"
2929
app:maxLines="4"

app/src/main/res/layout/assistant_setup_dialog.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
android:layout_height="wrap_content"
4242
android:layout_marginTop="16dp"
4343
app:cardBackgroundColor="?attr/colorSurfaceContainerHigh"
44-
app:cardCornerRadius="20dp"
44+
app:cardCornerRadius="16dp"
4545
app:layout_constraintEnd_toEndOf="parent"
4646
app:layout_constraintStart_toStartOf="parent"
4747
app:layout_constraintTop_toBottomOf="@id/dialog_title">
@@ -52,7 +52,7 @@
5252
android:layout_width="match_parent"
5353
android:layout_height="wrap_content"
5454
android:maxLines="8"
55-
android:padding="16dp"
55+
android:padding="12dp"
5656
tools:text="@string/digital_assistant_setup_message" />
5757
</com.google.android.material.card.MaterialCardView>
5858

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<androidx.appcompat.widget.AppCompatCheckedTextView xmlns:android="http://schemas.android.com/apk/res/android"
2+
xmlns:tools="http://schemas.android.com/tools"
3+
android:id="@android:id/text1"
4+
android:layout_width="fill_parent"
5+
android:layout_height="wrap_content"
6+
android:background="@drawable/single_choice_background"
7+
android:drawableStart="?android:attr/listChoiceIndicatorMultiple"
8+
android:drawablePadding="8dp"
9+
android:drawableTint="@color/single_choice_state_color"
10+
android:ellipsize="marquee"
11+
android:gravity="center_vertical|start"
12+
android:minHeight="?attr/dropdownListPreferredItemHeight"
13+
android:paddingStart="32dp"
14+
android:paddingLeft="?attr/dialogPreferredPadding"
15+
android:paddingTop="12dp"
16+
android:paddingEnd="32dp"
17+
android:paddingRight="?attr/dialogPreferredPadding"
18+
android:paddingBottom="12dp"
19+
android:textAlignment="viewStart"
20+
android:textAppearance="?attr/textAppearanceTitleMedium"
21+
android:textColor="@color/single_choice_state_color"
22+
tools:checked="true"
23+
tools:ignore="PrivateResource"
24+
tools:text="@string/theme_system" />
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<androidx.appcompat.widget.AppCompatCheckedTextView xmlns:android="http://schemas.android.com/apk/res/android"
2+
xmlns:tools="http://schemas.android.com/tools"
3+
android:id="@android:id/text1"
4+
android:layout_width="fill_parent"
5+
android:layout_height="wrap_content"
6+
android:background="@drawable/single_choice_background"
7+
android:drawableStart="?android:attr/listChoiceIndicatorSingle"
8+
android:drawablePadding="8dp"
9+
android:drawableTint="@color/single_choice_state_color"
10+
android:ellipsize="marquee"
11+
android:gravity="center_vertical|start"
12+
android:minHeight="?attr/dropdownListPreferredItemHeight"
13+
android:paddingStart="32dp"
14+
android:paddingLeft="?attr/dialogPreferredPadding"
15+
android:paddingTop="12dp"
16+
android:paddingEnd="32dp"
17+
android:paddingRight="?attr/dialogPreferredPadding"
18+
android:paddingBottom="12dp"
19+
android:textAlignment="viewStart"
20+
android:textAppearance="?attr/textAppearanceTitleMedium"
21+
android:textColor="@color/single_choice_state_color"
22+
tools:checked="true"
23+
tools:ignore="PrivateResource"
24+
tools:text="@string/theme_system" />

0 commit comments

Comments
 (0)