I want to create this layout
这是一个卡片视图(灰色视图)和图像视图(蓝色视图),我使用这个代码
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/abc_search_url_text_normal"
android:orientation="vertical">
<android.support.v7.widget.CardView
android:layout_width="match_parent"
android:layout_height="100dp"
android:layout_alignParentBottom="true"
android:layout_gravity="bottom"
android:layout_marginBottom="3dp"
android:paddingTop="5dp"
app:cardBackgroundColor="@color/abc_input_method_navigation_guard">
</android.support.v7.widget.CardView>
<ImageView
android:layout_width="100dp"
android:layout_height="100dp"
android:layout_gravity="bottom"
android:layout_marginBottom="30dp"
android:layout_marginRight="10dp"
android:scaleType="fitXY"
android:src="@drawable/abc_ratingbar_full_material" />
</FrameLayout>
但结果我的图像视图转到卡片视图的后面,我尝试使用相对布局而不是框架布局,但结果相同。
CardView 在 API 21+ 中默认具有标高,您可以将标高设置为小于 ImageView 的标高
<android.support.v7.widget.CardView xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:cardElevation="1dp"/>
<ImageView
android:id="@+id/image_view_user"
android:layout_width="48dp"
android:layout_height="48dp"
android:elevation="2dp"/>
在 Pre 21 中你可以使用
overlayView.bringToFront();
root.requestLayout();
root.invalidate();
如果您有不同的海拔,这在 21+ 中不起作用
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)