【发布时间】:2017-11-08 20:35:41
【问题描述】:
使用材料设计如何创建带有背景图像的工具栏。
以下是我想要的:
我正在尝试以下代码:
<?xml version="1.0" encoding="utf-8"?>
<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/actionBar"
android:layout_width="match_parent"
android:layout_height="200dp"
app:contentInsetEnd="0dp"
app:contentInsetStart="0dp"
android:minHeight="200dp">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/imageViewplaces"
android:src="@drawable/puri"
android:layout_gravity="center"/>
</android.support.v7.widget.Toolbar>
我得到的是:
【问题讨论】:
-
尝试使用'background'属性而不是'src'?
-
我试过了。一样的。图片不覆盖整个工具栏区域。
-
将
android:layout_width="match_parent"用于ImageView,因为工具栏是match_parent,以便在整个工具栏上应用图像。您应该将 ImageView 宽度修改为match_parent。wrap_content会根据ImageView中提供的图片显示图片的宽高 -
我试过静止图像不占据整个工具栏。首先是不是可能。在工具栏中相对放置菜单项和子视图