2016-01-19 3 views
4

Я положил LinearLayout1 в ToolBar. Затем еще пять LinearLayouts в LinearLayout1. Каждый ребенок LinearLayout имеет ImageView. Здесь моя проблема в том, что LinearLayout1 не соответствует ширине родителя. Это я показал на изображении (в красном круге). Черный цвет - это фон, который я дал ToolBar.LinearLayout внутри ToolBar не соответствует родительскому

<android.support.v7.widget.Toolbar 
    android:id="@+id/featured_bottomToolbar" 
    android:layout_width="match_parent" 
    android:layout_height="50dp" 
    android:layout_gravity="bottom" 
    android:background="#000000" 
    android:layout_alignParentBottom="true"> 


    <LinearLayout 
     android:orientation="horizontal" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent"> 

     <LinearLayout 
      android:orientation="horizontal" 
      android:layout_width="0dp" 
      android:layout_weight="2" 
      android:layout_height="match_parent"> 

      <ImageView 
       android:layout_width="match_parent" 
       android:layout_height="match_parent" 
       android:src="@drawable/menu_black_featured" 
       android:id="@+id/imageView" /> 
     </LinearLayout> 

     <LinearLayout 
      android:orientation="horizontal" 
      android:layout_width="0dp" 
      android:layout_weight="2" 
      android:layout_height="match_parent"> 

      <ImageView 
       android:layout_width="match_parent" 
       android:layout_height="match_parent" 
       android:src="@drawable/menu_grey_justin2" 
       android:id="@+id/imageView2" /> 
     </LinearLayout> 

     <LinearLayout 
      android:orientation="horizontal" 
      android:layout_width="0dp" 
      android:layout_weight="2" 
      android:layout_height="match_parent"> 

      <ImageView 
       android:layout_width="match_parent" 
       android:layout_height="match_parent" 
       android:src="@drawable/menu_grey_designers" 
       android:id="@+id/imageView3" /> 
     </LinearLayout> 

     <LinearLayout 
      android:orientation="horizontal" 
      android:layout_width="0dp" 
      android:layout_weight="2" 
      android:layout_height="match_parent"> 

      <ImageView 
       android:layout_width="match_parent" 
       android:layout_height="match_parent" 
       android:src="@drawable/menu_grey_categories" 
       android:id="@+id/imageView4" /> 
     </LinearLayout> 

     <LinearLayout 
      android:orientation="horizontal" 
      android:layout_width="0dp" 
      android:layout_weight="2" 
      android:layout_height="match_parent"> 

      <ImageView 
       android:layout_width="match_parent" 
       android:layout_height="match_parent" 
       android:src="@drawable/meny_grey_more2" 
       android:id="@+id/imageView5" /> 
     </LinearLayout> 

    </LinearLayout> 
</android.support.v7.widget.Toolbar> 

Выход, который у меня есть.

enter image description here

+1

почтовый индекс, чтобы мы могли помочь вам. –

+0

Вы используете панель инструментов для создания табула вручную? –

+0

Я опубликовал. Пожалуйста, пройдите через него и помогите. –

ответ

34

Добавьте следующие свойства к вашему элементу Toolbar.

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

По умолчанию значение contentInsetStart является 16dp. Вам нужно будет установить его на 0.

0

Try призвание:

mToolbar = (Toolbar) findViewById(R.id.featured_bottomToolbar); 
mToolbar.setContentInsetsAbsolute(0, 0); 

на ваш Toolbar экземпляре.

1
<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:app="http://schemas.android.com/apk/res-auto" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:orientation="vertical"> 

    <android.support.v7.widget.Toolbar 
     android:id="@+id/featured_bottomToolbar" 
     android:layout_width="match_parent" 
     android:layout_height="50dp" 
     android:layout_gravity="bottom" 
     android:background="#000000" 
     app:contentInsetLeft="0dp" 
     app:contentInsetStart="0dp" 
     android:layout_alignParentBottom="true"> 


     <LinearLayout 
      android:orientation="horizontal" 
      android:layout_width="match_parent" 
      android:layout_height="match_parent"> 

      <LinearLayout 
       android:orientation="horizontal" 
       android:layout_width="0dp" 
       android:layout_weight="2" 
       android:layout_height="match_parent"> 

       <ImageView 
        android:layout_width="match_parent" 
        android:layout_height="match_parent" 
        android:src="@drawable/menu_black_featured" 
        android:id="@+id/imageView" /> 
      </LinearLayout> 

      <LinearLayout 
       android:orientation="horizontal" 
       android:layout_width="0dp" 
       android:layout_weight="2" 
       android:layout_height="match_parent"> 

       <ImageView 
        android:layout_width="match_parent" 
        android:layout_height="match_parent" 
        android:src="@drawable/menu_grey_justin2" 
        android:id="@+id/imageView2" /> 
      </LinearLayout> 

      <LinearLayout 
       android:orientation="horizontal" 
       android:layout_width="0dp" 
       android:layout_weight="2" 
       android:layout_height="match_parent"> 

       <ImageView 
        android:layout_width="match_parent" 
        android:layout_height="match_parent" 
        android:src="@drawable/menu_grey_designers" 
        android:id="@+id/imageView3" /> 
      </LinearLayout> 

      <LinearLayout 
       android:orientation="horizontal" 
       android:layout_width="0dp" 
       android:layout_weight="2" 
       android:layout_height="match_parent"> 

       <ImageView 
        android:layout_width="match_parent" 
        android:layout_height="match_parent" 
        android:src="@drawable/menu_grey_categories" 
        android:id="@+id/imageView4" /> 
      </LinearLayout> 

      <LinearLayout 
       android:orientation="horizontal" 
       android:layout_width="0dp" 
       android:layout_weight="2" 
       android:layout_height="match_parent"> 

       <ImageView 
        android:layout_width="match_parent" 
        android:layout_height="match_parent" 
        android:src="@drawable/meny_grey_more2" 
        android:id="@+id/imageView5" /> 
      </LinearLayout> 

     </LinearLayout> 
    </android.support.v7.widget.Toolbar> 
</RelativeLayout> 
+0

я добавил: // в космическом макете Xmlns: приложение = "http://schemas.android.com/apk/res-auto" // в панели инструментов приложение: contentInsetLeft = "0dp" приложение: contentInsetStart = "0dp" –

-1

Кроме того, необходимо сделать следующее:

getSupportActionBar().setDisplayHomeAsUpEnabled(false); 
+0

Это бесполезно и сбой, если вы используете собственную панель инструментов. – SoftDesigner

Смежные вопросы