dotnet / dotnet/maui

Cannot change Slider height with handler Android. MAUI

Open
#10,259 10 comments 4 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

area-controls-slider platform/android s/needs-attention s/triaged s/verified t/bug
Dominant language
C#
Stars
23.3k
Forks
2k
Avg merge
1d 14h
Merged PRs (30d)
296

Description

Description

We cannot change Slider's height with handler in Android. MAUI

Steps to Reproduce

1.created a maui app;

2.add the following code in MainPage.xaml.cs:

   public partial class MainPage : ContentPage
{
    public MainPage()
    {
        InitializeComponent();
        Microsoft.Maui.Handlers.SliderHandler.Mapper.AppendToMapping("MyCustomization", (handler, view) =>
        {
#if ANDROID
            // Update slider thickness
            handler.PlatformView.LayoutParameters = new Android.Views.ViewGroup.LayoutParams(100, 100);
            handler.PlatformView.MinHeight = 100;
            handler.PlatformView.SetMinimumHeight(100);
#endif
        });
    }
}

3.deploy this demo to an android device, but it couldn't change the Slider's height .

But we can change other properties(e.g. Progress) with following code:

    handler.PlatformView.Min = 1;
    handler.PlatformView.Max = 100;
    handler.PlatformView.Progress = 50; // Set slider progress to 50%
Link to public reproduction project repository

You can reproduce this problem with above code.

Version with bug

Unknown/Other (please specify)

Last version that worked well

Unknown/Other

Affected platforms

Android, I was not able test on other platforms

Affected platform versions

android 9

Did you find any workaround?

No response

Relevant log output

No response

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the SliderHandler.Mapper customization shown in MainPage.xaml.cs and trace how the Android PlatformView applies layout parameters and minimum height. Reproduce the issue on Android 9 using the provided handler code, then verify that the Slider's height changes while the existing Min, Max, and Progress behavior remains intact.

Written by the indexing model from the issue text.

Assessment

Tech stack
android, csharp
Domain
mobile
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
52/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.