在ActionMode中删除工具栏标题页边空白

问题描述 投票:1回答:1

我想删除导航图标和我的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>

enter image description here

但是我无法更改模式操作以删除照片上的空间:enter image description here

java android toolbar android-actionmode
1个回答
0
投票

好,这很复杂而且很困难,但是我使用了像我建议的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;
   }
© www.soinside.com 2019 - 2024. All rights reserved.