1

I need Circle ImageView with Shadow(elevation) on version >=16, i decided to try FAB.

The problem: If fabsize - normal

If you choose fabCustomSize(75dp)>fabsize(normal) - working, but image are to small: fabcustomsize 75dp

XML:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@color/colorBlueLightLight"
    tools:context=".MainActivity">

    <LinearLayout
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_centerHorizontal="true"
        android:orientation="horizontal">

        <android.support.design.widget.FloatingActionButton
            android:id="@+id/floatingActionButton"
            android:layout_width="80dp"
            android:layout_height="80dp"
            android:layout_weight="1"
            android:clickable="true"
            app:backgroundTint="#C4C4C4"
            app:borderWidth="0dp"
            app:elevation="4dp"
            app:fabCustomSize="75dp"
            app:fabSize="normal"
            app:rippleColor="#25FAFAFA"
            app:srcCompat="@drawable/mute_2"
            app:useCompatPadding="false" />
    </LinearLayout>

The other two buttons have the same code

Chomui
  • 13
  • 6

1 Answers1

0

Solution 1

This solution works only for AndroidX, you can read @answer for migrating to AndroidX. Use app:maxImageSize="50dp" in your fab.

output

Solution 2

If you don't want to use AndroidX for now, then put this dimen in your dimens.xml

<dimen name="design_fab_image_size" tools:override="true">70dp</dimen>

Update

Don't set android:layout_width and android:layout_height if you are setting app:fabCustomSize. Then your fab will not be like square.

Khemraj Sharma
  • 46,529
  • 18
  • 168
  • 182
  • maxImageSize is available in `AndroidX` package. You will migrate to `AndroidX` support library in future for sure, so you can do it now. See https://stackoverflow.com/a/52517772/6891563 – Khemraj Sharma Sep 27 '18 at 09:40
  • I added a variable, it does the same thing as fabcustomsize, but the problem still remains. The normal size of the image - beyound the border [https://i.stack.imgur.com/QEqPv.jpg]. Small image size - don't beyond, but i need normal size image. By the way, why the images are not round, but some kind of oval image? – Chomui Sep 27 '18 at 10:31
  • Which variable you added? – Khemraj Sharma Sep 27 '18 at 10:53
  • i change design_fab_image_size to "50" and fubcustomsize to "80" it works. Thanks. – Chomui Sep 27 '18 at 10:55
  • Is there any issue remaining now? – Khemraj Sharma Sep 27 '18 at 10:56
  • it seems to be not – Chomui Sep 27 '18 at 10:58
  • What about square shape? – Khemraj Sharma Sep 27 '18 at 10:59
  • Everything is normal. In the beginning, when I just added design_fab_image_size, nothing has changed. When added the value of the variable fabcustomsize - the beginning of something to change. A couple of times changed the values and now everything works. Picture of a normal size, does not go abroad, shadows are present – Chomui Sep 27 '18 at 11:04