몇 가지 유사한 주제를 읽었지만이 문제에 대한 답을 찾지 못했습니다.툴바 레이아웃이 상위 너비와 일치하지 않습니다.
<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"이 줄을 전체 레이아웃이 아니라 레이아웃의 툴바 위젯에 적용하면 부모가 올바르게 채워지지만 투명도는 떨어집니다. 이게 도움이 될 수 있니?
MyToolbar의 테마는 무엇입니까? – Yupi
@Yupi <스타일 이름 = "MyToolbar"부모 = "ThemeOverlay.AppCompat.Dark.ActionBar"> <항목 이름 = "안드로이드 : homeAsUpIndicator"> 당김 @/BACK_ARROW 당신은 할 패딩 설정을 수동으로 시도 할 수 – fregomene
단지 제로. –