RelativeLayout с перекрывающимися представлениями - PullRequest
0 голосов
/ 24 декабря 2018

Мне нужно создать дизайн пользовательского интерфейса, как на картинке ниже.Я использовал RelativeLayout, но верх view прячется за CardView.Я пробовал так много способов, не мог сделать это.

enter image description here

вот мой код:

<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="150dp"
tools:context=".activity.LoginActivity">

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

    <android.support.v7.widget.CardView
        android:layout_width="match_parent"
        android:layout_height="150dp"
        android:elevation="4dp"
        android:layout_margin="10dp"
        >
    </android.support.v7.widget.CardView>

    <FrameLayout
        android:layout_width="100dp"
        android:layout_height="100dp"
        android:layout_marginStart="20dp"
        android:layout_marginLeft="20dp"
        android:background="@drawable/square_items">


        <ImageView
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:src="@drawable/ic_aboutus"/>

    </FrameLayout>

</RelativeLayout>

1 Ответ

0 голосов
/ 24 декабря 2018

Вам нужно положить ImageView в Cardview, чтобы высота стала равной для обоих.Попробуйте это

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="wrap_content">

    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content">

        <RelativeLayout
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginTop="10dp">

            <android.support.v7.widget.CardView
                android:layout_width="match_parent"
                android:layout_height="150dp"
                android:layout_marginStart="10dp"
                android:layout_marginTop="10dp"
                android:layout_marginEnd="10dp"
                android:layout_marginBottom="10dp"
                android:elevation="4dp"
                android:padding="10dp"
                app:cardCornerRadius="6dp">


            </android.support.v7.widget.CardView>
        </RelativeLayout>

        <android.support.v7.widget.CardView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginLeft="20dp">

            <ImageView
                android:layout_width="100dp"
                android:layout_height="100dp"
                android:src="@color/red" />


        </android.support.v7.widget.CardView>

    </RelativeLayout>

</RelativeLayout>
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...