嗨 我可以在不使用 xml 代码的情况下定义这个形状
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<gradient android:startColor="#34342C" android:endColor="#848486"
android:angle="90" />
<padding android:left="7dp" android:top="5dp" android:right="7dp"
android:bottom="5dp" />
<stroke android:width="1dp" android:color="#FFFFFF" />
</shape>
感谢您的帮助
最佳答案
是的
- 使用ShapeDrawable使用 padding 绘制矩形您需要
- 使用 Paint与适当的color和stroke width
- 使用 Linear gradient并将其作为shader添加到Paint中
关于android - 在JAVA代码中定义Drawable Shape,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6205354/