mbob98
mbob98

Reputation: 71

Is there a way to position a layer-list item more accurately?

I have been at work implementing a custom scrollbar for views, and have revisited the layer-list idea I found, since it seems to have a bigger chance of being a viable solution than I thought. My issue, however, is that I've lined up the thumb's layer-list item with the track's layer-list item underneath, but I can't keep it on the track.

Here's what my scrollbar looks like when it's at the top of the page (arrows will be moved later):

top

Then here at the bottom of the page (arrows will be moved later):

bottom

This is the XML code for the thumb:

<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">

    <item
        android:drawable="@drawable/ic_scroll_thumb_bmp"
        android:gravity="center"
        android:left="100dp"
        android:height="25dp">
        <margin android:top="50dp" />
    </item>

</layer-list>

I tried using the android:top and android:bottom values to move it around, but I could only get it to stay either within bounds on the top, or within bounds on the bottom, but not both. I saw some older usages online that suggest padding and/or margins would work in these, but after attempting to do so, nothing happened, as well as the IDE telling me it "wasn't allowed here".

How would I bound the thumb within the track? Are there values in layer-list or layer-list > item that would help me do so?

Upvotes: 0

Views: 94

Answers (0)

Related Questions