在 Android 的工具栏背景中添加图像
Add image in background of Toolbar in Android
我正在尝试做这样的事情:
我当前的工具栏代码:
<android.support.v7.widget.Toolbar
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/toolbar"
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:fitsSystemWindows="true"
android:minHeight="?attr/actionBarSize"
app:theme="@style/MyTheme.ActionBarStyle"
android:background="@android:color/transparent">
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_marginLeft="-10dp"
android:gravity="center">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/explore_morning"
android:contentDescription="@string/app_name" />
</RelativeLayout>
</android.support.v7.widget.Toolbar>
我的图像没有覆盖整个屏幕
设置工具栏背景解决了我的问题,而不是添加新的图像视图。
<android.support.v7.widget.Toolbar xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/explore_morning"
android:fitsSystemWindows="true"
android:minHeight="64dp"
app:theme="@style/MyTheme.ActionBarStyle">
</android.support.v7.widget.Toolbar>
我正在尝试做这样的事情:
我当前的工具栏代码:
<android.support.v7.widget.Toolbar
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/toolbar"
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:fitsSystemWindows="true"
android:minHeight="?attr/actionBarSize"
app:theme="@style/MyTheme.ActionBarStyle"
android:background="@android:color/transparent">
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_marginLeft="-10dp"
android:gravity="center">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/explore_morning"
android:contentDescription="@string/app_name" />
</RelativeLayout>
</android.support.v7.widget.Toolbar>
我的图像没有覆盖整个屏幕
设置工具栏背景解决了我的问题,而不是添加新的图像视图。
<android.support.v7.widget.Toolbar xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/explore_morning"
android:fitsSystemWindows="true"
android:minHeight="64dp"
app:theme="@style/MyTheme.ActionBarStyle">
</android.support.v7.widget.Toolbar>