计数为 android 的自定义购物车图标
Custom Cart icon with count for android
我必须显示带有计数的购物车图标,这是自定义图像
我使用购物车的普通图片,但对自定义图片一无所知
我有这张图片
我必须像这样显示这个购物车图标
我是否必须像第二张一样制作单独的图像,或者我可以使用我已有的那张吗
请帮帮我
提前致谢。
您可以简单地使用一个并在上面显示一个 TextView
包含项目的数量
用户可以将其用作 TextView 的背景
<?xml version="1.0" encoding="utf-8"?>
<shape
xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<corners android:radius="5dp"/>
<stroke android:color="#3CA9C1" android:width="3dp"/>
<solid android:color="#FFFFFF"/>
</shape>
你可以像这样简单地在图片上画文字,但是它的位置不太好,你得自己想办法了。
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#252525">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:src="@drawable/cart"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:background="@drawable/textview_background"
android:padding="5dp"
android:text="10"/>
</RelativeLayout>
我必须显示带有计数的购物车图标,这是自定义图像
我使用购物车的普通图片,但对自定义图片一无所知
我有这张图片
我必须像这样显示这个购物车图标
我是否必须像第二张一样制作单独的图像,或者我可以使用我已有的那张吗
请帮帮我
提前致谢。
您可以简单地使用一个并在上面显示一个 TextView
包含项目的数量
用户可以将其用作 TextView 的背景
<?xml version="1.0" encoding="utf-8"?>
<shape
xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<corners android:radius="5dp"/>
<stroke android:color="#3CA9C1" android:width="3dp"/>
<solid android:color="#FFFFFF"/>
</shape>
你可以像这样简单地在图片上画文字,但是它的位置不太好,你得自己想办法了。
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#252525">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:src="@drawable/cart"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:background="@drawable/textview_background"
android:padding="5dp"
android:text="10"/>
</RelativeLayout>