简体   繁体   English

如何向自定义浮动操作按钮添加图标和自定义textView

[英]how can I add an icon and a custom textView to a custom floating action button

I looked all over for 我四处寻找 在此处输入图片说明 examples and I hardly saw any floating action button with an icon and text view on it. 示例,我几乎看不到任何带有图标和文本视图的浮动操作按钮。

I want my MyCartBtn with icon and text on it. 我想要带有图标和文字的MyCartBtn。 So the idea is the count of the cart changes dynamically so I know how to set that code 所以这个想法是购物车的数量会动态变化,所以我知道如何设置该代码

public class MyCartBtn extends FloatingActionButton {
private Context mContext;
private MyTextView mTextView;
 }

code

    <?xml version="1.0" encoding="utf-8"?>
    <RelativeLayout 
    xmlns:android="http://schemas.android.com/apk/res/android"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:background="@color/transparent">

    <com.panera.bread.common.views.MyCartBtn
        android:id="@+id/cart_btn"
        android:layout_width="95dp"
        android:layout_height="95dp"
        android:background="@drawable/circular_icon"
        />

    <com.panera.bread.common.views.MyTextView
        android:id="@+id/cart_size"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="1"
        android:textColor="@android:color/white"/>



      </RelativeLayout>```

Have you tried using ` 您是否尝试过使用`

<com.panera.bread.common.views.MyCartBtn
    android:id="@+id/cart_btn"
    android:layout_width="95dp"
    android:layout_height="95dp"
    android:background="@drawable/circular_icon"
    />

<com.panera.bread.common.views.MyTextView
    android:id="@+id/cart_size"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="1"
    android:textAppearance="?android:attr/textAppearanceMedium"
    android:textColor="@android:color/white"/>
  </LinearLayout>`

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM