Skip to content

Commit 9a5ec35

Browse files
josefigueroa168dsn5ft
authored andcommitted
[Catalog] Update catalog preferences menu to a nested scroll view.
This change allows all preference options to be accessible in landscape mode. PiperOrigin-RevId: 423915710
1 parent 96fa85e commit 9a5ec35

File tree

2 files changed

+22
-17
lines changed

2 files changed

+22
-17
lines changed

catalog/java/io/material/catalog/preferences/CatalogPreferencesDialogFragment.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -68,11 +68,11 @@ public View onCreateView(
6868
@NonNull LayoutInflater layoutInflater,
6969
@Nullable ViewGroup viewGroup,
7070
@Nullable Bundle bundle) {
71-
LinearLayout container =
72-
(LinearLayout) layoutInflater.inflate(
73-
R.layout.mtrl_preferences_dialog, viewGroup, false);
71+
View container = layoutInflater.inflate(R.layout.mtrl_preferences_dialog, viewGroup, false);
72+
LinearLayout preferencesLayout = container.findViewById(R.id.preferences_layout);
7473
for (CatalogPreference catalogPreference : preferences.getPreferences()) {
75-
container.addView(createPreferenceView(layoutInflater, container, catalogPreference));
74+
preferencesLayout.addView(
75+
createPreferenceView(layoutInflater, preferencesLayout, catalogPreference));
7676
}
7777
return container;
7878
}

catalog/java/io/material/catalog/preferences/res/layout/mtrl_preferences_dialog.xml

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -13,20 +13,25 @@
1313
See the License for the specific language governing permissions and
1414
limitations under the License.
1515
-->
16-
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
17-
android:layout_width="match_parent"
18-
android:layout_height="wrap_content"
19-
android:orientation="vertical"
16+
<androidx.core.widget.NestedScrollView xmlns:android="http://schemas.android.com/apk/res/android"
2017
android:paddingTop="16dp"
2118
android:paddingLeft="16dp"
22-
android:paddingRight="16dp">
23-
24-
<TextView
19+
android:paddingRight="16dp"
20+
android:layout_width="match_parent"
21+
android:layout_height="wrap_content"
22+
android:overScrollMode="always">
23+
<LinearLayout
24+
android:id="@+id/preferences_layout"
25+
android:orientation="vertical"
2526
android:layout_width="match_parent"
26-
android:layout_height="wrap_content"
27-
android:gravity="center"
28-
android:paddingBottom="8dp"
29-
android:text="@string/preferences_screen_title"
30-
android:textAppearance="?attr/textAppearanceHeadline3"/>
27+
android:layout_height="wrap_content">
28+
<TextView
29+
android:layout_width="match_parent"
30+
android:layout_height="wrap_content"
31+
android:gravity="center"
32+
android:paddingBottom="8dp"
33+
android:text="@string/preferences_screen_title"
34+
android:textAppearance="?attr/textAppearanceHeadline3"/>
35+
</LinearLayout>
36+
</androidx.core.widget.NestedScrollView>
3137

32-
</LinearLayout>

0 commit comments

Comments
 (0)