在 android 中绘制自定义可绘制对象
draw custom drawable in android
如何绘制图片中附加的自定义可绘制对象?
我没有完整的代码,只是我应该如何进行的步骤以及指向高级自定义可绘制对象教程的任何链接就足够了。谢谢
您可以使用 9-patch 图像作为背景来实现此目的。
这是一个可以在线使用的好工具Simple Nine-patch Generator
以下是实现方法
- 为主布局视图使用白色背景(Table 例如视图)
- 为灰色框创建两个 9 色块图像。左边一个,右边一个
- 对于必须呈现为灰色的框,使用适当的 9 路径背景(左或右)。
我使用图层列表实现了它。任何人都需要查看代码..给我发消息。
<!-- Colored rectangle -->
<item>
<shape android:shape="rectangle" >
<stroke android:color="@color/color_black" />
<solid android:color="@color/col_gray_light" />
</shape>
</item>
<item
android:bottom="50dp"
android:left="-25dp"
android:right="-105dp"
android:top="-120dp">
<rotate android:fromDegrees="45" >
<shape android:shape="rectangle" >
<solid android:color="@color/color_white" />
</shape>
</rotate>
</item>
<item
android:bottom="63dp"
android:right="-15dp"
android:top="-40dp">
<rotate android:fromDegrees="45" >
<shape android:shape="rectangle" >
<solid android:color="@color/color_white" />
</shape>
</rotate>
</item>
<item
android:bottom="-40dp"
android:right="-20dp"
android:top="60dp">
<rotate android:fromDegrees="-45" >
<shape android:shape="rectangle" >
<solid android:color="@color/color_white" />
</shape>
</rotate>
</item>
如何绘制图片中附加的自定义可绘制对象?
我没有完整的代码,只是我应该如何进行的步骤以及指向高级自定义可绘制对象教程的任何链接就足够了。谢谢
您可以使用 9-patch 图像作为背景来实现此目的。
这是一个可以在线使用的好工具Simple Nine-patch Generator
以下是实现方法
- 为主布局视图使用白色背景(Table 例如视图)
- 为灰色框创建两个 9 色块图像。左边一个,右边一个
- 对于必须呈现为灰色的框,使用适当的 9 路径背景(左或右)。
我使用图层列表实现了它。任何人都需要查看代码..给我发消息。
<!-- Colored rectangle -->
<item>
<shape android:shape="rectangle" >
<stroke android:color="@color/color_black" />
<solid android:color="@color/col_gray_light" />
</shape>
</item>
<item
android:bottom="50dp"
android:left="-25dp"
android:right="-105dp"
android:top="-120dp">
<rotate android:fromDegrees="45" >
<shape android:shape="rectangle" >
<solid android:color="@color/color_white" />
</shape>
</rotate>
</item>
<item
android:bottom="63dp"
android:right="-15dp"
android:top="-40dp">
<rotate android:fromDegrees="45" >
<shape android:shape="rectangle" >
<solid android:color="@color/color_white" />
</shape>
</rotate>
</item>
<item
android:bottom="-40dp"
android:right="-20dp"
android:top="60dp">
<rotate android:fromDegrees="-45" >
<shape android:shape="rectangle" >
<solid android:color="@color/color_white" />
</shape>
</rotate>
</item>