-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- added "orientation" attr allowing for vertical support - updated tests and doc - added demo PiperOrigin-RevId: 695856298
- Loading branch information
1 parent
7f8d63b
commit 5bcda8a
Showing
8 changed files
with
374 additions
and
108 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
57 changes: 57 additions & 0 deletions
57
catalog/java/io/material/catalog/slider/SliderVerticalDemoFragment.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
/* | ||
* Copyright 2024 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 | ||
* | ||
* https://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. | ||
*/ | ||
|
||
package io.material.catalog.slider; | ||
|
||
import io.material.catalog.R; | ||
|
||
import static com.google.android.material.slider.SliderOrientation.HORIZONTAL; | ||
import static com.google.android.material.slider.SliderOrientation.VERTICAL; | ||
|
||
import android.os.Bundle; | ||
import android.view.LayoutInflater; | ||
import android.view.View; | ||
import android.view.ViewGroup; | ||
import androidx.annotation.NonNull; | ||
import androidx.annotation.Nullable; | ||
import com.google.android.material.materialswitch.MaterialSwitch; | ||
import com.google.android.material.slider.Slider; | ||
import io.material.catalog.feature.DemoFragment; | ||
|
||
/** | ||
* Fragment to display a few basic uses of the vertical {@link Slider} widget for the Catalog app. | ||
*/ | ||
public class SliderVerticalDemoFragment extends DemoFragment { | ||
|
||
@Nullable | ||
@Override | ||
public View onCreateDemoView( | ||
@NonNull LayoutInflater layoutInflater, | ||
@Nullable ViewGroup viewGroup, | ||
@Nullable Bundle bundle) { | ||
|
||
View view = | ||
layoutInflater.inflate( | ||
R.layout.cat_slider_demo_vertical, viewGroup, false /* attachToRoot */); | ||
|
||
Slider slider = view.findViewById(R.id.slider_vertical); | ||
MaterialSwitch switchButton = view.findViewById(R.id.switch_button); | ||
switchButton.setOnCheckedChangeListener( | ||
(buttonView, isChecked) -> slider.setOrientation(isChecked ? VERTICAL : HORIZONTAL)); | ||
|
||
return view; | ||
} | ||
} |
54 changes: 54 additions & 0 deletions
54
catalog/java/io/material/catalog/slider/res/layout/cat_slider_demo_vertical.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
<?xml version="1.0" encoding="utf-8"?><!-- | ||
Copyright 2024 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. | ||
--> | ||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" | ||
xmlns:app="http://schemas.android.com/apk/res-auto" | ||
android:layout_width="match_parent" | ||
android:layout_height="match_parent" | ||
android:padding="16dp"> | ||
|
||
<com.google.android.material.slider.Slider | ||
android:id="@+id/slider_vertical" | ||
android:layout_width="wrap_content" | ||
android:layout_height="350dp" | ||
android:layout_marginTop="64dp" | ||
android:orientation="vertical" | ||
android:value="8.09" | ||
android:valueFrom="0.0" | ||
android:valueTo="11.0" | ||
app:layout_constraintEnd_toEndOf="parent" | ||
app:layout_constraintStart_toStartOf="parent" | ||
app:layout_constraintTop_toTopOf="parent" | ||
app:thumbHeight="48dp" | ||
app:trackCornerSize="12dp" | ||
app:trackHeight="40dp" | ||
app:trackIconActive="@drawable/baseline_music_note_24" | ||
app:trackIconActiveColor="@color/m3_slider_active_tick_marks_color" | ||
app:trackIconActiveSize="20dp" | ||
app:trackIconInactive="@drawable/baseline_music_off_24" | ||
app:trackIconInactiveColor="@color/m3_slider_inactive_tick_marks_color" | ||
app:trackIconInactiveSize="20dp" /> | ||
|
||
<com.google.android.material.materialswitch.MaterialSwitch | ||
android:id="@+id/switch_button" | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:layout_marginBottom="128dp" | ||
android:checked="true" | ||
android:text="@string/cat_slider_vertical" | ||
app:layout_constraintBottom_toBottomOf="parent" | ||
app:layout_constraintEnd_toEndOf="parent" | ||
app:layout_constraintStart_toStartOf="parent" /> | ||
</androidx.constraintlayout.widget.ConstraintLayout> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.