سؤال

I have a custom selector for my gridview that appears on top of my gridview images when pressed. The issue is I don't know how to make the selector smaller. I currently use a rectangular shape, I dont know how to make this shape slightly smaller on each side.

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


    <item android:state_pressed="true"><shape android:shape="rectangle">
            <solid android:color="@color/dark_red_title_transparent" />
        </shape></item>

       </selector>
هل كانت مفيدة؟

المحلول 2

I found the answer basically use layer-list to do something like the following that basically makes the selector slightly smaller.

    <item android:state_pressed="true"><layer-list>
        <item android:left="12dip" android:right="12dip" android:top="12dp" android:bottom="12dp"><shape android:shape="rectangle">
                <solid android:color="@android:color/white" />
            </shape></item>

    </layer-list></item>

نصائح أخرى

You can use 9-patch drawable with transparent border as your selector.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top