单击并按住 bottomNavigationView 上的按钮会在其周围创建一个奇怪的 "shadow" 并显示一个黑框
clicking and holding on button on bottomNavigationView creates a weird "shadow" around it and shows a black box
我创建了一个带有浮动操作按钮的 bottomNavigationView,底部导航栏上的项目在点击或按住它们后表现得很奇怪:
我应该如何 change/disable 去除点击按钮后按钮周围的“阴影”和灰色框(按住按钮后出现)?
代码:
<com.google.android.material.bottomnavigation.BottomNavigationView
android:id="@+id/bottomNavigationView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="@style/bottomNavBar"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:menu="@menu/menu_final">
<com.google.android.material.floatingactionbutton.FloatingActionButton
android:id="@+id/fab"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_margin="2dp"
android:clickable="true"
android:focusable="true"
android:foregroundGravity="clip_horizontal"
android:theme="@style/fab"
app:srcCompat="@drawable/ic_add" />
</com.google.android.material.bottomnavigation.BottomNavigationView>
样式:
<style name="fab" parent="Widget.Design.FloatingActionButton">
<item name="android:backgroundTint">@color/white</item>
<item name="tint">@color/black</item>
</style>
<style name="bottomNavBar" parent="Widget.Design.BottomNavigationView">
<item name="android:background">@color/ground</item>
</style>
尝试设置app:itemRippleColor="@null"
或app:itemRippleColor="#0000"
(透明)
在您的底部导航视图中
我终于修复了它(它可能不是最好的解决方案,但...它有效)
要移除阴影,您只需将 colorControlHighlight 和 colorControlActivated 设置为 "@android:color/transparent" 到 bottomNavigationBar
要删除按住 Activity 按钮后出现的框,请添加:
bottomNavigationView.children.forEach {
(it as? ViewGroup)?.children?.forEach {
it.setOnLongClickListener { _ -> true }
}
}
我创建了一个带有浮动操作按钮的 bottomNavigationView,底部导航栏上的项目在点击或按住它们后表现得很奇怪:
我应该如何 change/disable 去除点击按钮后按钮周围的“阴影”和灰色框(按住按钮后出现)?
代码:
<com.google.android.material.bottomnavigation.BottomNavigationView
android:id="@+id/bottomNavigationView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="@style/bottomNavBar"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:menu="@menu/menu_final">
<com.google.android.material.floatingactionbutton.FloatingActionButton
android:id="@+id/fab"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_margin="2dp"
android:clickable="true"
android:focusable="true"
android:foregroundGravity="clip_horizontal"
android:theme="@style/fab"
app:srcCompat="@drawable/ic_add" />
</com.google.android.material.bottomnavigation.BottomNavigationView>
样式:
<style name="fab" parent="Widget.Design.FloatingActionButton">
<item name="android:backgroundTint">@color/white</item>
<item name="tint">@color/black</item>
</style>
<style name="bottomNavBar" parent="Widget.Design.BottomNavigationView">
<item name="android:background">@color/ground</item>
</style>
尝试设置app:itemRippleColor="@null"
或app:itemRippleColor="#0000"
(透明)
在您的底部导航视图中
我终于修复了它(它可能不是最好的解决方案,但...它有效)
要移除阴影,您只需将 colorControlHighlight 和 colorControlActivated 设置为 "@android:color/transparent" 到 bottomNavigationBar
要删除按住 Activity 按钮后出现的框,请添加:
bottomNavigationView.children.forEach {
(it as? ViewGroup)?.children?.forEach {
it.setOnLongClickListener { _ -> true }
}
}