0

I have this sort of weird behavior with SVG drawable where the quality is poor and blurry when using FrameLayout and LinearLayout. The poor quality vector drawable was fixed when parent views of ImageView is ConstraintLayout. Can anyone tell why is this happening? I read some article that ConstraintLayout is really good in terms of draw and measure performance but did not mention vector drawables on it.

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

    <androidx.appcompat.widget.LinearLayoutCompat
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:background="@android:color/white"
        android:orientation="vertical"
        android:gravity="center">

        <androidx.appcompat.widget.AppCompatTextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:paddingBottom="@dimen/margin_15"
            android:text="@string/receipt_label"
            android:textColor="@color/black_color"
            android:textSize="@dimen/text_style_emphasize_size"
            android:textStyle="bold" />

        <FrameLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginStart="@dimen/margin_32"
            android:layout_marginEnd="@dimen/margin_32"
            android:background="@drawable/drawable_rounded_corner"
            android:elevation="@dimen/elevation_2">

            <androidx.appcompat.widget.LinearLayoutCompat
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:gravity="center"
                android:orientation="vertical"
                android:padding="@dimen/margin_15">

                <androidx.appcompat.widget.AppCompatImageView
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:adjustViewBounds="true"
                    android:padding="@dimen/margin_32"
                    android:src="@drawable/ic_logo" />

                <androidx.appcompat.widget.AppCompatTextView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:padding="@dimen/padding_regular"
                    android:text="@string/date_time_placeholder"
                    android:textColor="@color/black_color" />

            </androidx.appcompat.widget.LinearLayoutCompat>

        </FrameLayout>

        <FrameLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginStart="@dimen/margin_32"
            android:layout_marginEnd="@dimen/margin_32"
            android:background="@drawable/drawable_rounded_corner"
            android:elevation="@dimen/elevation_2">

            <View
                android:layout_width="match_parent"
                android:layout_height="2dp"
                android:layout_marginStart="@dimen/space_10"
                android:layout_marginEnd="@dimen/space_10"
                android:layerType="software"
                android:background="@drawable/dashline" />

                <androidx.appcompat.widget.LinearLayoutCompat
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:gravity="center"
                    android:orientation="vertical"
                    android:padding="@dimen/receipt_padding">

                    <androidx.appcompat.widget.AppCompatTextView
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_margin="@dimen/margin_regular"
                        android:text="@string/receipt_total_amount_paid_label"
                        android:textColor="@color/black_color" />

                    <androidx.appcompat.widget.AppCompatTextView
                        android:id="@+id/tvAmount"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:text="@string/amount_value"
                        android:textColor="@color/black_color"
                        android:textSize="@dimen/numpad_text_size"
                        android:textStyle="bold" />

                </androidx.appcompat.widget.LinearLayoutCompat>

        </FrameLayout>

        <FrameLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginStart="@dimen/margin_32"
            android:layout_marginEnd="@dimen/margin_32"
            android:background="@drawable/drawable_rounded_corner"
            android:elevation="@dimen/elevation_2">

            <View
                android:layout_width="match_parent"
                android:layout_height="2dp"
                android:layout_marginStart="@dimen/space_10"
                android:layout_marginEnd="@dimen/space_10"
                android:layerType="software"
                android:background="@drawable/dashline" />

                <androidx.appcompat.widget.LinearLayoutCompat
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:gravity="center"
                    android:orientation="vertical"
                    android:padding="@dimen/receipt_padding">

                    <androidx.appcompat.widget.LinearLayoutCompat
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content">

                        <androidx.appcompat.widget.AppCompatTextView
                            android:layout_width="match_parent"
                            android:layout_height="wrap_content"
                            android:layout_weight="1"
                            android:text="@string/receipt_paid_by_label"
                            android:textStyle="bold"
                            android:textColor="@color/black_color" />

                        <androidx.appcompat.widget.AppCompatImageView
                            android:layout_width="wrap_content"
                            android:layout_height="match_parent"
                            android:layout_weight="0"
                            android:scaleType="fitEnd"
                            android:src="@drawable/ic_visa" />

                    </androidx.appcompat.widget.LinearLayoutCompat>

                    <androidx.appcompat.widget.LinearLayoutCompat
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content">

                        <androidx.appcompat.widget.AppCompatTextView
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:text="@string/receipt_transaction_id_label"
                            android:textStyle="bold"
                            android:textColor="@color/black_color" />

                        <androidx.appcompat.widget.AppCompatTextView
                            android:layout_width="match_parent"
                            android:layout_height="wrap_content"
                            android:gravity="end"
                            android:paddingStart="@dimen/receipt_padding"
                            android:paddingEnd="0dp"
                            android:text="@string/receipt_transaction_id_placeholder"
                            android:textStyle="bold"
                            android:textColor="@color/btn_start_color" />

                    </androidx.appcompat.widget.LinearLayoutCompat>

                </androidx.appcompat.widget.LinearLayoutCompat>

        </FrameLayout>

        <androidx.appcompat.widget.LinearLayoutCompat
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:paddingStart="@dimen/powered_logo_width"
            android:paddingEnd="@dimen/powered_logo_width"
            android:paddingBottom="@dimen/margin_32"
            android:orientation="vertical">

            <FrameLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_marginTop="@dimen/margin_32"
                android:layout_marginStart="@dimen/margin_10"
                android:layout_marginEnd="@dimen/margin_10"
                android:background="@drawable/button_bg"
                android:elevation="@dimen/elevation_2">

                <androidx.appcompat.widget.AppCompatTextView
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:paddingStart="@dimen/margin_32"
                    android:paddingTop="@dimen/margin_15"
                    android:paddingEnd="@dimen/margin_32"
                    android:paddingBottom="@dimen/margin_15"
                    android:text="@string/button_email_receipt"
                    android:textColor="@color/black_color"
                    android:textSize="@dimen/sub_text_size"
                    android:textAllCaps="true"
                    android:gravity="center"
                    android:textStyle="bold" />

            </FrameLayout>

            <FrameLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_marginTop="@dimen/margin_15"
                android:layout_marginStart="@dimen/margin_10"
                android:layout_marginEnd="@dimen/margin_10"
                android:layout_marginBottom="@dimen/margin_10"
                android:background="@drawable/gradient_done_btn"
                android:elevation="@dimen/elevation_2">

                <androidx.appcompat.widget.AppCompatTextView
                    style="@style/AppTextViewDropShadow"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:gravity="center"
                    android:paddingStart="@dimen/margin_32"
                    android:paddingTop="@dimen/margin_15"
                    android:paddingEnd="@dimen/margin_32"
                    android:paddingBottom="@dimen/margin_15"
                    android:text="@string/button_done"
                    android:textAllCaps="true"
                    android:textSize="@dimen/sub_text_size"
                    android:textStyle="bold" />

            </FrameLayout>

        </androidx.appcompat.widget.LinearLayoutCompat>

        <include
            layout="@layout/powered_by_blue_layout"/>

    </androidx.appcompat.widget.LinearLayoutCompat>

</FrameLayout>

Running on Android 7.1.1

2
  • can you show your FrameLayout and LinearLayout xml?
    – Teo
    Commented Aug 19, 2021 at 3:06
  • @Teo question updated Commented Aug 19, 2021 at 5:34

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.