android - 减少android中工具栏导航图标的左边距

标签 android navigation icons toolbar back

因为我是 android 的新手,我在我的工具栏中设置了后退按钮,我想从左边减少它的填充/边距我该怎么做? 提前致谢。

这是我的设计代码

<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary"
app:popupTheme="@style/AppTheme.PopupOverlay">
<TextView
android:id="@+id/tripidtoolbar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="left"
android:text="name"
android:textColor="#ffffff"
android:textSize="18sp"
android:textStyle="bold"
/>
<TextView
android:id="@+id/dayNotoolbar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="right"
android:textColor="#ffffff"
android:layout_marginRight="10dp"
android:text="day"
android:textAllCaps="true"
android:textSize="18sp"
android:textStyle="bold"
/>
</android.support.v7.widget.Toolbar>

这是我手动设置后退按钮的方式

protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_vouchers_details);
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
toolbar.setNavigationIcon(R.drawable.arrowbackwhite);
toolbar.setNavigationOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
onBackPressed();
}
});
setSupportActionBar(toolbar);

这是我的屏幕(back button having left margin)

最佳答案

将这些行添加到您的工具栏 xml 中

app:contentInsetLeft="0dp"
app:contentInsetStart="0dp"
app:contentInsetStartWithNavigation="0dp"

关于android - 减少android中工具栏导航图标的左边距,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36767195/

相关文章:

android - 决定我应该使用哪种技术来开发基于电子商务域的 Android 应用程序

android - vuforia 插件和 prime31 facebook 插件之间的冲突

android - Write Multiple Blocks 命令在 NfcV 上失败

android - 调用 Fragment 构造函数导致异常,kotlin?

android - 为什么 Android Studio 在 res/drawable-v24 中创建 ic_launcher_foreground 而在 res/drawable 中创建 ic_launcher_background.xml?

css - Font Awesome unicode 不显示

android - PieChart 在 achartEngine 中添加 ScrollView ?

c# - 如何计算转弯方向

Java 商店注册应用程序导航机制

ios - 关于 iOS 应用程序的图像和图标名称以及图标大小的最终说明