在android系统中cardview创建视图 [英] create view over cardview in android

查看:190
本文介绍了在android系统中cardview创建视图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要创建这种布局结果

I want to create this layout

这是我使用code一cardview(灰色视图)和ImageView的(蓝色视图)

this is a cardview (gray view) and imageview(blue view) for that i use this code

<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我的图像视图我尝试代替的FrameLayout但同样的结果reletivelayout。

but in result my image view going to back of cardview i try reletivelayout instead of framelayout but same result.

推荐答案

尝试:


  • 使用一个RelativeLayout的

  • Use a RelativeLayout

对齐ImageView的父权/结束,并添加右/结束保证金

Align the ImageView to the parent right/end and add a right/end margin

对齐FAB到卡视图顶部,并添加阴性切缘

Align the FAB to the top of the card view and add a negative margin

结果

<RelativeLayout
    ...>
    <CardView
    android:id="@+id/cardView"
    android:layout_width="match_parent"
    android:layout_height="120dp"
    />

   <ImageView
    android:id="@+id/fab"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentRight="true"
    android:layout_alignTop="@id/cardView"
    android:layout_marginTop="-32dp"
    android:layout_marginRight="20dp"
   />

</RelativeLayout>

这篇关于在android系统中cardview创建视图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆