【问题标题】:Imageview over card border - how to solve it?卡片边框上的 Imageview - 如何解决?
【发布时间】:2013-08-15 22:32:58
【问题描述】:

我正在制作一个带有类似于 google now 界面的应用程序,其中包含用于内容的卡片。

首先请看这张图片:http://imgur.com/oLSSvIn

我设法创建了卡片并将内容添加到其中,但我的图像视图正在卡片边框(阴影线)上方,如蓝色箭头所示。

请问如何在imageview下制作卡片灰色边框星?我尝试为图像视图添加边距并为卡片添加底部/顶部填充,但没有任何成功。

这里是卡片bg的代码:

<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
    <item>
        <shape android:shape="rectangle"
            android:dither="true">

            <corners android:radius="0dp"/>

            <solid android:color="#bdbdbd" />



        </shape>
    </item>

    <item android:bottom="2dp">
        <shape android:shape="rectangle"
            android:dither="true">

            <corners android:radius="0dp" />

            <solid android:color="@android:color/white" />


        </shape>
    </item>
</layer-list>

以及包含内容的活动:

<?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="wrap_content"
    android:layout_marginBottom="4dp"
    android:layout_marginLeft="6dp"
    android:layout_marginRight="6dp"
    android:layout_marginTop="4dp"
    android:background="@drawable/friend_card_profile_bg" >

    <ImageView
        android:id="@+id/friendPic"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginBottom="1dp"
        android:adjustViewBounds="true"
        android:scaleType="fitXY"
        android:src="@drawable/friend_testpic" />

    <TextView
        android:id="@+id/friendUsername"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginBottom="2dp"
        android:layout_marginLeft="6dp"
        android:layout_marginTop="4dp"
        android:layout_toRightOf="@+id/friendPic"
        android:fontFamily="sans-serif-condensed"
        android:text="@string/profile_username"
        android:textColor="#7f7f7f"
        android:textSize="19dp" />

    <TextView
        android:id="@+id/friendLinksCounter"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_below="@+id/friendUsername"
        android:layout_marginLeft="6dp"
        android:layout_toRightOf="@+id/friendPic"
        android:fontFamily="sans-serif"
        android:text="@string/profile_links_counter"
        android:textColor="#acacac"
        android:textSize="14dp" />

    <TextView
        android:id="@+id/friendFriendsCounter"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_below="@+id/friendLinksCounter"
        android:layout_marginLeft="6dp"
        android:layout_toRightOf="@+id/friendPic"
        android:fontFamily="sans-serif"
        android:text="@string/profile_friends_counter"
        android:textColor="#acacac"
        android:textSize="14dp" />

</RelativeLayout>

谢谢你

【问题讨论】:

    标签: android xml android-layout


    【解决方案1】:

    尝试在相对布局的底部使用 2dp 填充,这应该会调整内容,使其全部位于阴影之上。

    【讨论】:

    • 工作,按你说的添加填充!
    猜你喜欢
    • 2014-12-12
    • 1970-01-01
    • 2021-05-04
    • 1970-01-01
    • 1970-01-01
    • 2016-03-20
    • 1970-01-01
    • 2015-03-11
    • 2021-09-16
    相关资源
    最近更新 更多