Bobby
Bobby

Reputation: 659

Seekbar thumb image gets cut off

I have setup a seekbar with a custom thumb image. The initial image is set by XML file and shows fine no cut off. When I make change to image the image gets cut off on the bottom. The seekbar XML is loaded into a framelayout. Seekbar works fine but movement runs past view. So the when I run to max the top gets cut off and when I rum to minimum the bottom gets cut. Both images are the same size.

Here is the initial XML

       <SeekBar
    android:id="@+id/seekBarr"
    android:layout_width="300dp"
    android:layout_height="70dp"
    android:layout_marginLeft="-100dp"
    android:layout_marginTop="230dp"
    android:progressDrawable="@drawable/mastersliderback"
    android:rotation="270"
    android:thumb="@drawable/imgsliderred70" />

here is the code that loads new image.

    Drawable thumb1 = getResources().getDrawable(       R.drawable.imgsliderred70_rate);
    SliderRed.setThumb(thumb1);

Upvotes: 1

Views: 3397

Answers (2)

Trake Vital
Trake Vital

Reputation: 1167

  1. Go to gradle.build under root directory
  2. Right-click the line that goes like this: classpath 'com.android.tools.build:gradle:4.2.2'
  3. And press the sync now option (if no such option exists then try a different answer)
  4. Press the blue buttons to the left on both pop-up screens (if there are any)
  5. Wait for the installations to finish
  6. Rebuild the project

And just like magic it suddenly works

Upvotes: 0

Bobby
Bobby

Reputation: 659

I found some additional information on the issue.It was not the image size as I thought but the offset and padding. Here is a the changes I made and the image is no longer clipped.

       <SeekBar
    android:id="@+id/seekBarr"
    android:layout_width="300dp"
    android:layout_height="70dp"
    android:layout_marginLeft="-100dp"
    android:layout_marginTop="230dp"
    android:paddingLeft="35dp"
    android:paddingRight="35dp"
    android:progressDrawable="@drawable/mastersliderback"
    android:rotation="270"
    android:thumb="@drawable/imgsliderred70"
    android:thumbOffset="8dp" />

Upvotes: 4

Related Questions