我想删除导航图标和我的actionMode标题之间的空格。由于[
,我设法将其从工具栏中删除了<style name="AppTheme" parent="Theme.MaterialComponents.Light">
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorPrimary</item>
<item name="toolbarStyle">@style/cusToolbarStyle</item>
</style>
<style name="cusToolbarStyle" parent="@style/Widget.MaterialComponents.Toolbar">
<item name="titleMargin">0dp</item>
<item name="contentInsetStartWithNavigation">0dp</item>
<item name="contentInsetStart">0dp</item>
<item name="android:background">@color/white</item>
</style>
好,这很复杂而且很困难,但是我使用了像我建议的LayoutInspector @cgb_pandey。因此,我找到了关闭ImageView的系统标识符,并将以下代码添加到onPrepareActionMode方法中:
@Override
public boolean onPrepareActionMode(ActionMode mode, Menu menu) {
AppCompatImageView imageView = findViewById(com.google.android.material.R.id.action_mode_close_button);
if (imageView != null) {
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
params.setMargins(0, 0, 0, 0);
imageView.setLayoutParams(params);
}
return false;
}