Создание наложения в Android studio - PullRequest
0 голосов
/ 22 мая 2018

В настоящее время я делаю приложение для Android и ищу вдохновение на картинке, как показано ниже.Я пытаюсь создать оверлей в правом верхнем углу первого устройства на картинке, и я понятия не имею, как это делается.enter image description here

Ответы [ 2 ]

0 голосов
/ 22 мая 2018

Использование alpha свойство

<?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="match_parent">

<RelativeLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content">
<LinearLayout
    android:background="#FFFF33"
    android:layout_width="match_parent"
    android:layout_height="200dp">
    <TextView
        android:textAlignment="textEnd"
        android:text="Sample Text View Sample Text View Sample Text View"
        android:layout_width="match_parent"
        android:layout_height="wrap_content" />
</LinearLayout>

    <RelativeLayout
        android:alpha="0.5"
        android:background="@color/colorPrimary"
        android:layout_alignParentEnd="true"
        android:layout_alignParentRight="true"
        android:layout_width="100dp"
        android:layout_height="200dp">
    </RelativeLayout>
</RelativeLayout>


</RelativeLayout>

Выход будет выглядеть как

enter image description here

*********** EDITED AS PER OP'S REQUIREMENT ***********

<?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="match_parent">

<RelativeLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content">
    <LinearLayout
        android:background="#FFFF33"
        android:layout_width="match_parent"
        android:layout_height="200dp">

    </LinearLayout>

    <RelativeLayout
        android:alpha="0.5"
        android:background="@color/colorPrimary"
        android:layout_alignParentEnd="true"
        android:layout_alignParentRight="true"
        android:layout_width="100dp"
        android:layout_height="200dp">
    </RelativeLayout>
    <TextView
        android:textAlignment="textEnd"
        android:text="Sample Text View Sample Text View Sample Text View"
        android:layout_width="match_parent"
        android:layout_height="wrap_content" />
</RelativeLayout>
</RelativeLayout>
0 голосов
/ 22 мая 2018

добавить два макета, один для фона, а другой для верхней части.затем добавьте верхний фоновый цвет фона белый прозрачный.

пример XML-макета, приведенный ниже

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<RelativeLayout
    android:layout_width="match_parent"
    android:layout_height="200dp"
    android:background="#c11316">
    <TextView
        android:text="25"
        android:textColor="#ffffff"
        android:layout_centerVertical="true"
        android:layout_alignParentEnd="true"
        android:layout_marginEnd="30dp"
        android:textSize="30dp"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content" />
</RelativeLayout>
<RelativeLayout
    android:layout_width="match_parent"
    android:layout_height="200dp"
    android:layout_marginEnd="150dp"
    android:background="#33e4e4e4">
    <TextView
        android:text="Your Things"
        android:textColor="#ffffff" 
        android:layout_centerVertical="true"
        android:layout_centerHorizontal="true"
        android:textSize="30dp"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content" />
</RelativeLayout>

output look like this

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