VikasSharmalp
VikasSharmalp

Reputation: 492

Some of the icons are not showing in some android devices

I am using the normal way to setup vector icons in my ImageView in android . In some devices the icons are not visible , blank spaces comes over there, don't know why happening. This is happening in android pie devices only

These are some of the codes that i used to setup my icons. Icons are perfectly showing in debug device , but after release some devices creating problems.

<LinearLayout 
 android:layout_width="match_parent"
  android:padding="5sp"
  android:gravity="center"
  android:id="@+id/home_dr"
  android:layout_marginBottom="5sp"
  android:orientation="horizontal"
  android:layout_height="50sp">

<ImageView android:layout_width="50sp"
   android:padding="13sp"
   android:gravity="center"
   android:tint="@color/white"
   android:src="@drawable/ic_home"
   android:layout_height="50sp"/>

<TextView 
  android:layout_width="match_parent"
  android:layout_marginStart="10sp"
  android:text="Home"
  android:textColor="@color/white"
  android:textStyle="bold"
  android:gravity="center|start"
  android:layout_height="match_parent"/>
</LinearLayout>

Hare are some of the image you can understand well

Upvotes: 0

Views: 585

Answers (2)

Payam Asefi
Payam Asefi

Reputation: 2757

add this in your apps buil.gradle and inside defaultConfig tag:

vectorDrawables.useSupportLibrary = true

and then use AppCompatImageView with app:srcCompat. like this:

            <android.support.v7.widget.AppCompatImageView
           android:layout_width="50sp"
                   android:padding="13sp"
                   android:gravity="center"
                   android:tint="@color/white"
                   app:srcCompat="@drawable/ic_home"
                   android:layout_height="50sp" />

Upvotes: 3

Mini Chip
Mini Chip

Reputation: 969

In case of vector icons , your suppose to set them as srcCompact instead of src in image view .

app:srcCompat="@drawable/your_vector_name"

and in your build.gradle , check if you have enabled the vector drawable .

android {
defaultConfig {
    vectorDrawables.useSupportLibrary = true
}
}

For API Level 21 suppory , add this in you activity AppCompatDelegate.setCompatVectorFromResourcesEnabled(true);

Upvotes: 1

Related Questions