1

몇 가지 유사한 주제를 읽었지만이 문제에 대한 답을 찾지 못했습니다.툴바 레이아웃이 상위 너비와 일치하지 않습니다.

<android.support.design.widget.AppBarLayout android:layout_width="match_parent" 
android:layout_height="wrap_content" 
xmlns:android="http://schemas.android.com/apk/res/android" 
xmlns:app="http://schemas.android.com/apk/res-auto" 
android:background="#99000000"> 

<RelativeLayout 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content"> 

    <android.support.v7.widget.Toolbar 
     android:id="@+id/toolbar_transparent" 
     android:layout_height="wrap_content" 
     android:layout_width="match_parent" 
     android:fitsSystemWindows="true" 
     android:minHeight="?attr/actionBarSize" 
     app:theme="@style/MyToolbar"> 

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

    <TextView 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:textColor="@android:color/white" 
     android:textAppearance="?android:attr/textAppearanceMedium" 
     android:layout_centerInParent="true" 
     android:id="@+id/toolbar_title" /> 

</RelativeLayout> 

을 그리고 여기 내 코드는 활동이다 : 나는 도구 모음 사용자 정의 레이아웃을

toolbar = (Toolbar) findViewById(R.id.toolbar_transparent); 
    setSupportActionBar(toolbar); 
    getSupportActionBar().setDisplayHomeAsUpEnabled(true); 
    getSupportActionBar().setDisplayShowTitleEnabled(false); 

내 도구 모음 여전히 좌우 한 패딩을 부모의 폭을 기입하지 않습니다. 나는 다양한 솔루션을 시도했습니다. 내 코드에 무슨 문제가 있습니까? 문제는 툴바가 반투명해야한다는 것입니다. 그래서 레이아웃 android : background = "# 99000000"에서이 줄을 사용합니다. 전체 레이아웃에 적용하고 툴바는 반투명하지만 폭은 부모를 채우지 않습니다. 그러나 android : background = "# 99000000"이 줄을 전체 레이아웃이 아니라 레이아웃의 툴바 위젯에 적용하면 부모가 올바르게 채워지지만 투명도는 떨어집니다. 이게 도움이 될 수 있니?

+0

MyToolbar의 테마는 무엇입니까? – Yupi

+0

@Yupi <스타일 이름 = "MyToolbar"부모 = "ThemeOverlay.AppCompat.Dark.ActionBar"> <항목 이름 = "안드로이드 : homeAsUpIndicator"> 당김 @/BACK_ARROW 당신은 할 패딩 설정을 수동으로 시도 할 수 – fregomene

+0

단지 제로. –

답변

1

이 레이아웃보십시오 : 반 Transperant에 대한

toolbar

<?xml version="1.0" encoding="utf-8"?> 
<android.support.design.widget.AppBarLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:id="@+id/general_appbar" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:background="@null"> 

    <android.support.v7.widget.Toolbar 
     android:layout_width="match_parent" 
     android:layout_height="?attr/actionBarSize" 
     android:background="#99000000"> 

     <TextView 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:gravity="center_horizontal" 
      android:text="Login" 
      android:textSize="20sp" /> 
    </android.support.v7.widget.Toolbar> 

</android.support.design.widget.AppBarLayout> 

출력 :

enter image description here

+0

답변을 주셔서 감사합니다. 그러나 문제는 해결되지 않았습니다. ( – fregomene

+0

@fregomene 대답을 편집했습니다 ... – rafsanahmad007

+0

왼쪽 및 오른쪽 패딩은 변경되지 않았습니다. 내 레이아웃도 반투명하지만 패딩은 처리 할 수 ​​없습니다. – fregomene