I tried in many ways, but the one that worked for me was. Seekbar user inside FrameLayout
<FrameLayout android:id="@+id/VolumeLayout" android:layout_width="match_parent" android:layout_height="match_parent" android:layout_above="@id/MuteButton" android:layout_below="@id/volumeText" android:layout_centerInParent="true"> <SeekBar android:id="@+id/volume" android:layout_width="500dp" android:layout_height="60dp" android:layout_gravity="center" android:progress="50" android:secondaryProgress="40" android:progressDrawable="@drawable/seekbar_volume" android:secondaryProgressTint="@color/tint_neutral" android:thumbTint="@color/tint_neutral" />
And in the Code. Set up a callback before rendering on the Seekbar, where you can change the width and height of the Seekbar. I did this part in C #, so the code I used was
var volumeSlider = view.FindViewById<SeekBar>(Resource.Id.home_link_volume); var volumeFrameLayout = view.FindViewById<FrameLayout>(Resource.Id.linkVolumeFrameLayout); void OnPreDrawVolume(object sender, ViewTreeObserver.PreDrawEventArgs e) { volumeSlider.ViewTreeObserver.PreDraw -= OnPreDrawVolume; var h = volumeFrameLayout.Height; volumeSlider.Rotation = 270.0f; volumeSlider.LayoutParameters.Width = h; volumeSlider.RequestLayout(); } volumeSlider.ViewTreeObserver.PreDraw += OnPreDrawVolume;
Here I add a listener to the PreDraw event, and when it fires, I delete PreDraw so that it does not go into an infinite loop.
Therefore, when Pre Draw is executed, I select Height of FrameLayout and assign it to Seekbar. And set the rotation of the search bar to 270. Since my search bar is inside the Layout frame and its gravity is set to Center. I do not need to worry about the translation. Since Seekbar always stays in the middle of Frame Layout.
The reason I removed the EventHandler is because seekbar.RequestLayout (); Let's make this event executed again.
soan saini May 10 '19 at 4:36 2019-05-10 04:36
source share