Fix the category preference aligement problem

- The reason is the fixed value of the paddingStart.
- Change the value when display size is changing.

Fixes: 177968087
Test: manual test
Change-Id: Ibdcdc51e4ee7d8c327d03f0a4aee5891efe1cbd0
This commit is contained in:
Sunny Shao
2021-01-26 16:06:53 +08:00
parent b9de689848
commit 3ea112404a
3 changed files with 29 additions and 4 deletions

View File

@@ -19,14 +19,13 @@
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingLeft="24dp"
android:paddingStart="24dp"
android:paddingRight="?android:attr/listPreferredItemPaddingRight"
android:paddingEnd="?android:attr/listPreferredItemPaddingEnd"
android:background="?android:attr/selectableItemBackground"
android:baselineAligned="false"
android:layout_marginTop="16dp"
android:gravity="center_vertical">
android:gravity="center_vertical"
style="@style/PreferenceCategoryStartMargin">
<RelativeLayout
android:layout_width="0dp"
@@ -57,6 +56,5 @@
android:textColor="?android:attr/textColorSecondary"
android:maxLines="10"
style="@style/PreferenceSummaryTextStyle"/>
</RelativeLayout>
</LinearLayout>

View File

@@ -0,0 +1,22 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (C) 2021 The Android Open Source Project
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<resources>
<style name="PreferenceCategoryStartMargin">
<item name="android:paddingLeft">24dp</item>
<item name="android:paddingStart">24dp</item>
</style>
</resources>

View File

@@ -22,4 +22,9 @@
<!-- 0.8 Spacing, 0.8/11 = 0.072727273 -->
<item name="android:letterSpacing">0.072727273</item>
</style>
<style name="PreferenceCategoryStartMargin">
<item name="android:paddingLeft">?android:attr/listPreferredItemPaddingLeft</item>
<item name="android:paddingStart">?android:attr/listPreferredItemPaddingStart</item>
</style>
</resources>