Android / Styling زر: الخلفية أيضًا خلف السحب اليسرى وقابل للرسم اليمين
-
03-10-2019 - |
سؤال
أقوم بتصميم زر يمكن أن يتغير عرضه في البرنامج من خلال محتوى مختلف. حصلت على ملفات PNG من المصمم مثل هذا:
[Left Border] [Background (just a strip with the gradient)] [Right Border]
اعتقدت أنني بخير مع تعيين خصائص الزر مثل هذا:
Background: Background.png
Drawable left: LeftBorder.png
Drawable right: RightBorder.png
ولكن لن يكون هكذا ؛) في الوقت الحالي ، تبدأ الخلفية. هل استخدام تلك الخصائص القابلة للرسم ليست بالطريقة الصحيحة في هذه الحالة؟
هنا هو الرمز:
<Button
android:text="@+id/Button01"
android:id="@+id/Button01"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:drawableLeft="@drawable/top_loaction_left"
android:drawableRight="@drawable/top_loaction_right"
android:background="@drawable/top_loaction_bg"></Button>
..
المحلول
ما تحتاجه هو صورة 9 تصحيح.
http://developer.android.com/guide/developing/tools/draw9patch.html
لا تنتمي إلى StackOverflow