Рисование андроида: передний план над изображением только в XML - PullRequest
0 голосов
/ 16 мая 2019

У меня есть ImageView, который отображается как @ID, который не будет отвечать на android:foreground или android:alpha

Я пытался связываться с различными параметрами XML, такими как вес, расположение и т. Д.

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    style="@style/WatchStyle"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:background="@drawable/bg"
    android:foreground="@drawable/ring"
    android:orientation="vertical">

    <LinearLayout
        android:id="@id/top_container"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_gravity="center"
        android:layout_marginStart="28.0dip"
        android:layout_marginTop="18.0dip"
        android:layout_marginEnd="28.0dip"
        android:layout_marginBottom="1.0dip"
        android:gravity="center"
        android:orientation="horizontal">

        <LinearLayout
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="center"
            android:layout_marginStart="1.0dip"
            android:layout_marginEnd="1.0dip"
            android:orientation="vertical">

            <TextView
                android:id="@id/time_text_view"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_gravity="center"
                android:layout_marginTop="-4.0dip"
                android:layout_marginBottom="1.0dip"
                android:fontFamily="sans-serif-medium"
                android:orientation="vertical"
                android:text="13:26"
                android:textColor="#ff88bbff"
                android:textSize="@dimen/timeFontSize"
                android:textStyle="bold" />
        </LinearLayout>
    </LinearLayout>

    <ImageView
        android:id="@id/graph_view"
        android:layout_width="fill_parent"
        android:layout_height="0.0dip"
        android:layout_marginHorizontal="15.0dip"
        android:layout_weight="1.0"
        android:contentDescription="@string/blank" />

    <LinearLayout
        android:id="@id/top_container"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_gravity="center"
        android:layout_marginStart="2.0dip"
        android:layout_marginEnd="2.0dip"
        android:layout_marginBottom="1.0dip"
        android:gravity="center"
        android:orientation="horizontal">

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="center"
            android:fontFamily="sans-serif-medium"
            android:text="  "
            android:textColor="#ffffffff"
            android:textSize="@dimen/glucoseFontSizeRound" />

        <LinearLayout
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="center"
            android:layout_marginStart="1.0dip"
            android:layout_marginEnd="1.0dip"
            android:orientation="vertical">

            <TextView
                android:id="@id/egv_text_view"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_gravity="center"
                android:fontFamily="sans-serif-medium"
                android:text="136"
                android:textColor="#ffffffff"
                android:textSize="@dimen/glucoseFontSizeRound" />

            <TextView
                android:id="@id/egv_unit_view"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_gravity="center"
                android:layout_marginTop="-6.0dip"
                android:layout_marginBottom="14.0dip"
                android:fontFamily="sans-serif-medium"
                android:text="@string/mgdl"
                android:textColor="#ddddddff"
                android:textSize="@dimen/mgdlFontSizeRound" />
        </LinearLayout>

        <ImageView
            android:id="@id/trend_rate_view"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="center"
            android:layout_marginStart="4.0dip"
            android:layout_marginBottom="5.0dip"
            android:contentDescription="@string/blank"
            android:foregroundGravity="center"
            android:src="@drawable/single_up" />
    </LinearLayout>
</LinearLayout>

Насколько я понимаю, android:foreground="@drawable/ring" должно рисовать кольцевой рисунок поверх всего. Однако graph_view ImageView все еще накладывает его. Similary, включая android:alpha="0.5", не сделает ImageView полупрозрачным.

Это циферблат приложения-монитора для Android-диабетика, который, честно говоря, настолько уродлив, насколько это возможно. Поэтому я пытаюсь по крайней мере изменить внешний вид в пределах возможностей, который является только файлом макета watch_face_round.xml.

Мне удалось добавить фоновое изображение, изменить макет и некоторые цвета, а также добавить кольцо, окружающее фоновое изображение. Результат пока таков: https://drive.google.com/file/d/1JNjyfgoq4EAJPIo05a5rokSWt7JM5-sv/view?usp=sharing

Но, как вы можете видеть, график в центре (вышеупомянутый ImageView) перекрывает его. Я понятия не имею, откуда на самом деле появляется график, но я должен предположить, что он генерируется циферблатом или фактически отправляется из телефонного приложения, которое передает цифры на циферблат.

У меня нет доступа ни к одному из файлов java, только к декомпилированному приложению. Любая помощь приветствуется.

...