-
Notifications
You must be signed in to change notification settings - Fork 3.1k
[Slider] Fixed behaviour when Slider is in a scrolling container #4511
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
manabu-nakamura
wants to merge
3
commits into
material-components:master
from
manabu-nakamura:slider8
Closed
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
2aec718
[Slider] Fixed behaviour when Slider is in a scrolling container
manabu-nakamura 415dc4c
[Slider] Fixed behaviour when Slider is in a scrolling container
manabu-nakamura 58e771c
[Slider] Fixed behaviour when Slider is in a scrolling container
manabu-nakamura File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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/SliderVerticalScrollContainerDemoFragment.java
This file contains hidden or 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 2019 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 android.os.Bundle; | ||
import android.view.LayoutInflater; | ||
import android.view.View; | ||
import android.view.ViewGroup; | ||
import android.widget.LinearLayout; | ||
|
||
import androidx.annotation.Nullable; | ||
|
||
import com.google.android.material.slider.Slider; | ||
import com.google.android.material.slider.SliderOrientation; | ||
|
||
import io.material.catalog.R; | ||
import io.material.catalog.feature.DemoFragment; | ||
|
||
/** | ||
* A fragment that displays a list of vertical {@link Slider} inside a HorizontalScrollView to | ||
* showcase how touch events are handled. | ||
*/ | ||
public class SliderVerticalScrollContainerDemoFragment extends DemoFragment { | ||
|
||
@Override | ||
public View onCreateDemoView( | ||
LayoutInflater layoutInflater, @Nullable ViewGroup viewGroup, @Nullable Bundle bundle) { | ||
View view = | ||
layoutInflater.inflate( | ||
R.layout.cat_slider_demo_vertical_scroll, viewGroup, false /* attachToRoot */); | ||
LinearLayout sliderContainer = view.findViewById(R.id.sliderContainer); | ||
for (int i = 0; i < 50; i++) { | ||
Slider slider = new Slider(layoutInflater.getContext()); | ||
slider.setValueTo(11f); | ||
slider.setOrientation(SliderOrientation.VERTICAL); | ||
sliderContainer.addView( | ||
slider, | ||
ViewGroup.LayoutParams.WRAP_CONTENT, | ||
ViewGroup.LayoutParams.MATCH_PARENT); | ||
} | ||
return view; | ||
} | ||
} |
31 changes: 31 additions & 0 deletions
31
catalog/java/io/material/catalog/slider/res/layout/cat_slider_demo_vertical_scroll.xml
This file contains hidden or 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,31 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<!-- | ||
Copyright 2019 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. | ||
--> | ||
<HorizontalScrollView | ||
xmlns:android="http://schemas.android.com/apk/res/android" | ||
android:layout_width="match_parent" | ||
android:layout_height="match_parent"> | ||
|
||
<LinearLayout | ||
android:id="@+id/sliderContainer" | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" | ||
android:paddingLeft="16dp" | ||
android:paddingRight="16dp"> | ||
|
||
|
||
</LinearLayout> | ||
</HorizontalScrollView> |
This file contains hidden or 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 hidden or 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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you explain this
1.2
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is difficult for me to explain it...
If scaledTouchSlop is not divided by 1.2, it is difficult to slide (drag) vertical sliders. Try it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this also applicable for the vertical scroll or is it specific to this horizontal scroll?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems to be specific to horizontal scroll. Don't you think so?