AndroidTV Leanback library default navigation scaling makes vector drawable edges scratched, jagged, ugly

189 views Asked by At

Inserting VectorDrawable graphic inside viewholders in main grid of leanback makes them look ugly when focused. There is some scaling issue that i cannot resolve.

Here is simple example in normal application:

ic_vawe.xml

<vector xmlns:android="http://schemas.android.com/apk/res/android"
    android:width="986.5dp"
    android:height="87.27dp"
    android:viewportWidth="986.5"
    android:viewportHeight="87.27">
  <path
      android:fillColor="#FF000000"
      android:pathData="M464.46,86.61c-24.27,0.49 -63.93,0.66 -62,0.66h584V26.68C716.37,26.72 694.13,78.17 464.46,86.61Z"
      android:strokeAlpha="0.5"
      android:fillAlpha="0.5"/>
</vector>

Activity.kotlin

class MainActivity : AppCompatActivity() {
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_main)

        var iv = this.findViewById<ImageView>(R.id.imageView_1);
        var d3 = ContextCompat.getDrawable(this, R.drawable.ic_wave);
        iv.setImageDrawable(d3);

        iv.setOnClickListener {
            iv.scaleY = iv.scaleY + 0.6F;
        }
    }
}

Layout

<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout 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"
    tools:context=".MainActivity">

    <ImageView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:id="@+id/imageView_1"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintLeft_toLeftOf="parent"
        app:layout_constraintRight_toRightOf="parent"
        app:layout_constraintTop_toTopOf="parent" />

</androidx.constraintlayout.widget.ConstraintLayout>

When im scaling this vector up, then i got those shattered edges (look at video): android_simple_example

That behaviour is extremely visible when navigating in AndroidTV Leanback library where there is a lot of navigation related scaling. Image is sharp only in one state... Look at those ugly edges:

ATV_REAL_LIFE_EXAMPLe

Please, help me smooth this edges od VectorDrawables in android TV project. Do you have any ideas?

1

There are 1 answers

0
Oncky On

Please try use PNGs images instead of xml drawables.