[英]Android Studio: Floating Action Button: elevation works, but not as it should
I need Circle ImageView with Shadow(elevation) on version >=16, i decided to try FAB. 我需要版本> = 16的带有Shadow(elevation)的Circle ImageView,我决定尝试使用FAB。
The problem: If fabsize - normal 问题: 如果fabsize-正常
If you choose fabCustomSize(75dp)>fabsize(normal) - working, but image are to small: fabcustomsize 75dp 如果选择fabCustomSize(75dp)> fabsize(normal)-有效,但图像很小: fabcustomsize 75dp
XML: 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 另外两个按钮具有相同的代码
This solution works only for AndroidX, you can read @answer for migrating to AndroidX. 此解决方案仅适用于AndroidX,您可以阅读@answer迁移到AndroidX。 Use
app:maxImageSize="50dp"
in your fab. 在您的晶圆厂中使用
app:maxImageSize="50dp"
。
If you don't want to use AndroidX for now, then put this dimen in your dimens.xml
如果您暂时不想使用AndroidX,请
dimens.xml
放入您的dimens.xml
<dimen name="design_fab_image_size" tools:override="true">70dp</dimen>
Don't set android:layout_width
and android:layout_height
if you are setting app:fabCustomSize
. 如果要设置
app:fabCustomSize
不要设置android:layout_width
和android:layout_height
。 Then your fab will not be like square. 那么您的晶圆厂将不会像正方形。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.