سؤال

أحاول رسم مستطيل دائري مع حدود حوله باستخدام فئة تمتد على شكل طيب (انظر هنا) وكل شيء يعمل إلا أن القابلية للعلاج يبدو أنه يقطع بعض الحدود لأن الشكل نفسه لا يمتد خارج تلك الحدود.

لا توجد طريقة لتعويض المكان الذي يبدأ فيه الرسم القابل للتشكيل بحيث يكون هناك بعض الحشوة بين حدود الشكل نفسه والقماش؟ لقد جربت كل من appledrawable.setBounds إلى أكبر من الحجم الجوهري للشكل و appedrawlable. هل يجب أن أكون فئة فرعية يمكن رسمها في حين أن؟

هل كانت مفيدة؟

المحلول

يمكنك التفاف الذي يمكنك تشكيله باستخدام أقحم (inset_shape.xml):

    <inset xmlns:android="http://schemas.android.com/apk/res/android"
     android:drawable="@drawable/your_shape_drawable" android:insetBottom="10dip"
     android:insetLeft="10dip" android:insetRight="10dip" android:insetTop="10dip"
     android:visible="true" />

ثم فقط استخدم inset_shape ما تحتاج إليه.

نصائح أخرى

جرب هذا في السحب الخاص بك ...!

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

    <solid android:color="#e1e1e1" />

    <stroke
        android:width="2dp"
        android:color="#808080" />

    <corners android:radius="10dp" />

    <padding
        android:bottom="5dp"
        android:left="5dp"
        android:right="5dp"
        android:top="5dp" />

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