我想画一个这样的自定义形状

android - 在Android中绘制自定义形状-LMLPHP

我试图将其用作TextView,但是单击它引起了我的麻烦,因为箭头旁边的底部蓝色部分被认为是图像的一部分..所以我希望我的形状仅是白色和橙色部分
我应该如何绘制这样的形状?通过代码或XML不要期望完整的代码,只是给我一个主意或指出正确的方向。

最佳答案

我通过将原始图像裁剪为两种形状解决了点击问题
然后将它们粘合到xml中,并在textviews上添加侦听器,只丢弃底部的蓝色部分

android - 在Android中绘制自定义形状-LMLPHP

    <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>

07-24 09:50
查看更多