Android ROI фон - PullRequest
       27

Android ROI фон

0 голосов
/ 29 апреля 2019

Я пытаюсь создать вид с фоном и областью интереса, как на этом изображении:

enter image description here

Как создать такой фон в Android? Мне удалось создать квадрат с черной непрозрачностью и желтым обводкой следующим образом:

   <View
        android:background="@color/black_with_80_alpha"
        android:layout_width="0dp"
        android:layout_height="0dp"
        custom:layout_constraintTop_toTopOf="@+id/roi"
        custom:layout_constraintBottom_toBottomOf="@id/roi"
        custom:layout_constraintRight_toRightOf="parent"
        custom:layout_constraintLeft_toRightOf="@+id/roi"/>

<View
        android:background="@color/black_with_80_alpha"
        android:layout_width="0dp"
        android:layout_height="0dp"
        custom:layout_constraintTop_toTopOf="@+id/roi"
        custom:layout_constraintBottom_toBottomOf="@id/roi"
        custom:layout_constraintRight_toLeftOf="@id/roi"
        custom:layout_constraintLeft_toLeftOf="parent"/>

<View
        android:background="@color/black_with_80_alpha"
        android:layout_width="0dp"
        android:layout_height="0dp"
        custom:layout_constraintTop_toBottomOf="@+id/toolbar"
        custom:layout_constraintBottom_toTopOf="@id/roi"
        custom:layout_constraintRight_toRightOf="parent"
        custom:layout_constraintLeft_toLeftOf="parent"/>

<View
        android:background="@color/black_with_80_alpha"
        android:layout_width="0dp"
        android:layout_height="0dp"
        custom:layout_constraintTop_toBottomOf="@+id/roi"
        custom:layout_constraintBottom_toBottomOf="parent"
        custom:layout_constraintRight_toRightOf="parent"
        custom:layout_constraintLeft_toLeftOf="parent"/>
<View
        android:id="@+id/roi"
        android:layout_width="0dp"
        android:layout_height="0dp"
        custom:layout_constraintDimensionRatio="1:1"
        android:layout_margin="50dp"
        android:background="@drawable/qr_roi_bg"
        custom:layout_constraintStart_toStartOf="parent"
        custom:layout_constraintEnd_toEndOf="parent"
        custom:layout_constraintTop_toTopOf="parent"
        custom:layout_constraintBottom_toBottomOf="parent"
        />

Это желтый штрих bg:

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="rectangle">
    <solid android:color="@color/transparent" />
    <stroke android:color="@color/greenish_yellow" android:width="1dp"/>
</shape>

Это рисует красивый точный квадрат с ровным желтым штрихом. Вопрос в том, как я могу создать эти желтые углы.

...