我想画一个这样的自定义形状
我试图将它用作 TextView 但它导致我点击时出现问题,因为箭头旁边的底部蓝色部分被认为是图像的一部分..所以我希望我的形状只是白色和橙色部分 我应该如何绘制这样的形状?通过代码或 XML 不要指望完整的代码,只要给我想法或指出正确的方向。
最佳答案
我通过将原始图像裁剪成两个形状来解决点击问题 然后在 xml 中将它们粘合在一起,并在 textviews 上添加监听器,只丢弃底部的蓝色部分
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center">
<TextView
android:id="@+id/explore_rectangle_txt"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/explore_rectangle"
/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/explore_rectangle_txt"
android:background="@drawable/explore_arrow"
/>
</RelativeLayout>
关于android - 在android中绘制自定义形状,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38659387/