2

I looked all over forenter image description here 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. 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>```
Zoe
  • 27,060
  • 21
  • 118
  • 148
Vijay
  • 191
  • 1
  • 1
  • 9
  • Possibly a duplicate of: https://stackoverflow.com/questions/33671196/floatingactionbutton-with-text-instead-of-image – Stephen Nov 01 '17 at 17:21
  • @Stephen I did try the above example, but here in my scenario, I do have a button where icon is squeezed in toward top and the text view towards bottom. In the example you mentioned that just tell us how to add text view – Vijay Nov 01 '17 at 18:09

1 Answers1

-1

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>`
Vijay
  • 191
  • 1
  • 1
  • 9
Sai Anaru
  • 1
  • 1