Gas*_*tti 7 android material-design
我正在尝试使用FAB,但内部的图标位于按钮的右下角:
这是xml中的FAB定义:
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<com.google.android.material.floatingactionbutton.FloatingActionButton
android:id="@+id/centerLocationButton"
style="@style/Widget.MaterialComponents.FloatingActionButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_margin="@dimen/pro_arriving_map_location_button_padding"
android:src="@drawable/ic_my_location"
app:backgroundTint="@color/white"
app:fabSize="mini" />
</RelativeLayout>
Run Code Online (Sandbox Code Playgroud)
我究竟做错了什么?
小智 6
这似乎是设计支持库v28.0.0中的错误。
我可以通过编程设置scaleType来解决这个问题。
对于Java / Kotlin代码中的情况:
centerLocationButton.setScaleType(ImageView.ScaleType.CENTER)
Run Code Online (Sandbox Code Playgroud)
而不是android:src尝试app:srcCompat。FAB 是您唯一使用的东西吗,因为如果是(根据您发布的图片判断),也许您不需要relativelayout作为父级,您可以使用android:layout_gravity="bottom|end"
| 归档时间: |
|
| 查看次数: |
2002 次 |
| 最近记录: |