计算Android高程以获得Aspect 4:3

时间:2016-10-19 18:07:03

标签: java android android-layout android-cardview aspect

enter image description here您好我使用海拔高度为6dp的卡片视图

但是在我的代码中

height_4_3 = Functions.GetHeight4_3(parent.getWidth())


holder.parent_image.getLayoutParams().height = height_4_3;
holder.parent_image.requestLayout();

我有一个4:1方面的文本视图

holder.parent_text_view.getLayoutParams().height = height_4_3 / 3
holder.parent_text_view.requestLayout();

我需要减去方面4:3和4:1中的数字高程,将元素放在另一个上

更新

    <android.support.v7.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:card_view="http://schemas.android.com/apk/res-auto"
    card_view:cardElevation="6dp"
    android:layout_width="match_parent"
    android:id="@+id/parent_card_view"
    android:layout_height="200dp"
    card_view:cardCornerRadius="4dp"
    card_view:cardUseCompatPadding="true">

    <FrameLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent">

        <LinearLayout
            android:orientation="vertical"
            android:layout_width="match_parent"
            android:id="@+id/parent_image"
            android:layout_height="100dp">

            <ImageView
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                card_view:srcCompat="@drawable/login_1"
                android:id="@+id/image_course"
                android:elevation="2dp"
                android:scaleType="centerCrop"
                android:src="@drawable/login_1" />
        </LinearLayout>

        <LinearLayout
            android:orientation="vertical"
            android:layout_width="match_parent"
            android:layout_gravity="bottom"
            android:layout_height="100dp"
            android:id="@+id/parent_text_view">

            <TextView
                android:text="TextView"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:id="@+id/textView3"
                android:textColor="@color/BLUE_HIGHT" />
        </LinearLayout>

    </FrameLayout>

0 个答案:

没有答案