我想将 ImageView 置于工具栏顶部的中心并使其重叠。
它应该是这样的:
黑色矩形应该是工具栏,带有半圆的灰色矩形是我想要放置在工具栏顶部的 ImageView,以便半圆与工具栏重叠。
我的工具栏如下所示:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent" android:layout_height="match_parent">
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/actionbar_bg"
/>
</RelativeLayout>
现在,如果我将 ImaveView 放在顶部,它就太大了:
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="0dp"
android:layout_centerHorizontal="true"
android:src="@drawable/addbtn_bg"
android:adjustViewBounds="true"
/>
但是如果我设置它android:layout_alignBottom="@id/toolbar"
那么它就完美适合但半圆不重叠:
有什么办法可以实现这个目标吗? 也许通过使用类似指南之类的东西来仅使 ImageView 的矩形部分对齐?
谢谢。
最佳答案
我认为你必须有一个单独的半圆,它使用below="@id/toolbar"
关于android - 缩放 ImageView 以适应 ToolBar 并重叠,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29607404/