如何开发一个卡片视图,其高度必须根据屏幕尺寸进行响应

时间:2017-01-17 11:55:38

标签: android android-cardview

我有一张cardview但它的高度在不同的手机中有所不同。如何修复所有Android设备的响应问题。如果设置最小高度在这种情况下不会有太大帮助。请帮帮我

我使用的PFB Xml代码:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:card_view="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="wrap_content">

    <android.support.v7.widget.CardView
        android:id="@+id/card_view"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        card_view:cardCornerRadius="4dp"
        android:layout_margin="10dp">

        <RelativeLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:padding="20dp"
            >

        <RelativeLayout
            android:id="@+id/main_layout"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginBottom="10dp"
            >
            <RelativeLayout
                android:id="@+id/icons"
                android:layout_width="55dp"
                android:layout_height="55dp"
                android:layout_marginRight="10dp"
                android:background="@drawable/circle_background">

                <ImageView
                    android:layout_width="40dp"
                    android:layout_height="40dp"
                    android:layout_centerInParent="true"
                    android:src="@mipmap/ic_dvr_white_48dp"
                    android:tint="#ffffff" />
            </RelativeLayout>

            <TextView
                android:id="@+id/title"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:fontFamily="sans-serif"
                android:text="Intro to Html"
                android:textColor="#000"
                android:layout_toEndOf="@+id/icons"
                style="@android:style/TextAppearance.Large"
                />

            <TextView
                android:id="@+id/subtitle"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_below="@+id/title"
                android:layout_marginBottom="5dp"
                android:fontFamily="sans-serif"
                android:text="HTML Basics"
                android:textColor="@android:color/darker_gray"
                android:textStyle="italic"
                android:layout_toEndOf="@+id/icons"
                style="@android:style/TextAppearance.Medium"

                />
</RelativeLayout>

        <RelativeLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_below="@+id/main_layout"
            android:id="@+id/subtitle_content"
            android:padding="10dp"
            >
            <TextView
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:text="Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book."
                android:id="@+id/description"
                style="@android:style/TextAppearance.Small"
                android:maxEms="4"
                />

            <TextView
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:text="Role : Mutual Fund Planner "
                android:id="@+id/role"
                android:layout_below="@+id/description"
                style="@android:style/TextAppearance.Small"
                />
            <TextView
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:text="12 min "
                android:id="@+id/durration"
                android:layout_below="@+id/role"
                style="@android:style/TextAppearance.Small"
                />


        </RelativeLayout>
            <Button
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_below="@+id/subtitle_content"
                android:text="Begin Lesson"/>
        </RelativeLayout>
    </android.support.v7.widget.CardView>

</LinearLayout>

0 个答案:

没有答案