2017-09-25 86 views
0

我试图将imageview对齐到我的工具栏的最左侧,但它没有发生。我试着计算器其他的解决方案,但没有为我工作将布局对齐到最左侧工具栏android

check out this image

<android.support.v7.widget.Toolbar 
     android:id="@+id/my_toolbar" 
     android:layout_width="match_parent" 
     android:layout_height="?attr/actionBarSize" 
     android:background="#fff" 
     android:elevation="4dp" 
     android:gravity="start" 
     android:theme="@style/ThemeOverlay.AppCompat.ActionBar" 
     app:popupTheme="@style/ThemeOverlay.AppCompat.Light"> 

     <LinearLayout 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" 
      android:weightSum="10"> 

      <ImageView 
       android:layout_width="0dp" 
       android:layout_height="wrap_content" 
       android:layout_gravity="start" 
       android:layout_weight="2" 
       android:padding="10dp" 
       android:src="@drawable/app_icon_book_sumary_one" /> 
     </LinearLayout> 
    </android.support.v7.widget.Toolbar> 
+0

你的结果是这张图片吗? –

+0

[如何删除Android工具栏左边距?](https://stackoverflow.com/questions/31063962/how-to-remove-left-margin-of-android-toolbar) –

回答

2

添加这两条线工具栏里面工作

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

对于我只有线已经app:contentInsetStart =“0dp”解决了问题 –

2

将此属性工具栏上

app:contentInsetStartWithNavigation="0dp 
+0

它可能重复它不起作用...工具栏已经在极端的左侧,但在LinearLayout中有一些余量,我不知道为什么 –

+0

我可以看到你的图片上的工具栏没有完全对齐到左侧 –

+0

我的光标在LinearLayout上,所以它显示线性布局的边界。当光标在工具栏上时,边框移动到最左边。 :) –

相关问题