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

标签 android xml shapes

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

enter image description here

我试图将它用作 TextView 但它导致我点击时出现问题,因为箭头旁边的底部蓝色部分被认为是图像的一部分..所以我希望我的形状只是白色和橙色部分 我应该如何绘制这样的形状?通过代码或 XML 不要指望完整的代码,只要给我想法或指出正确的方向。

最佳答案

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

enter image description here

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

相关文章:

android - 如何切换图库的适配器

android - 改造响应在 Android 中返回 null

java - 在 Android 中创建波形 UI

android - 在不浪费空间android的情况下创建三角形xml

java - 没有从我的自定义 Cordova 插件 (Android) 获取回调

android - 在 android 应用程序中单击按钮调用条码扫描器

ruby-on-rails - 获取 XML 文件 POST 请求以使用 Ruby on Rails 解析

java - 将 XML 数据追加到 ArrayList

java - 如何在Java中获取Shape对象的x坐标

android - 造型玻璃效果