【问题标题】:How to customize cardview?如何自定义卡片视图?
【发布时间】:2015-06-12 07:17:18
【问题描述】:

我怎样才能以这种方式自定义卡片视图(左上角)?

以我的方式,如果我添加 3 个有色框(蓝色、灰色、白色),我总是会在 cardview 框的周边得到一个细边框。 有什么例子吗? 谢谢。

【问题讨论】:

  • 我认为cardview是不可能的

标签: android customization android-cardview


【解决方案1】:

你尝试过相对布局吗?

<?xml version="1.0" encoding="utf-8"?>
<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="wrap_content">

    <android.support.v7.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android"
                        xmlns:app="http://schemas.android.com/apk/res-auto"
                        android:id="@+id/card_view"
                        android:layout_width="match_parent"
                        android:layout_height="230dp"
                        android:layout_marginBottom="@dimen/cardMarginVertical"
                        android:layout_marginLeft="@dimen/cardMarginHorizontal"
                        android:layout_marginRight="@dimen/cardMarginHorizontal"
                        android:layout_marginTop="@dimen/cardMarginVertical"
                        app:cardCornerRadius="2dp"
                        app:cardElevation="2dp"
                        app:cardPreventCornerOverlap="false"
                        app:contentPadding="0dp">

        <RelativeLayout
                            android:layout_width="match_parent"
                            android:layout_height="match_parent">
            <LinearLayout
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:orientation="horizontal">
                <!--Circle image View-->
                <de.hdodenhof.circleimageview.CircleImageView
                        android:layout_width="50dp"
                        android:layout_height="50dp"
                        android:layout_marginLeft="270dp"
                        android:layout_marginTop="220dp"
                        android:id="@+id/circleViewDiscount"
                        android:src="@drawable/border_white"/>

                <TextView
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:text="10.19\nSaturday\n 30th August 2015"
                        android:textSize="23dp"
                        android:textColor="#08ec38"
                        android:id="@+id/textViewPirceTag"/>
            </LinearLayout>

            <LinearLayout
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:margin_Top="50dp" <!--Style the height-->
            android:orientation="horizontal"> 
                    <!--Add element here-->
                </LinearLayout>
            </RelativeLayout>    
        </android.support.v7.widget.CardView>    
    </FrameLayout>

【讨论】:

  • 很高兴帮助@SERG,我忘了告诉你你需要在你的gradle中编译“compile 'de.hdodenhof:circleimageview:1.2.1”的圆形图像
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2016-07-02
  • 2023-03-05
  • 1970-01-01
  • 2021-10-30
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多