2017-09-25 90 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上,所以它顯示線性佈局的邊界。當光標在工具欄上時,邊框移動到最左邊。 :) –

相關問題