Rubinder
Rubinder

Reputation: 47

Android button images gets blurry?

I have a few buttons in my app where I have applied circular PNG images on them but the edges gets pixelated. I don't know how to nine patch a circular image. If anybody knows a different way of doing it?

Upvotes: 1

Views: 1628

Answers (3)

umerk44
umerk44

Reputation: 2817

You didn't provide enough information e.g screen shot? code? but any ways you should use nine patch images if you are not providing separate image in each drawable directory. For further detail Go to This link. Hope this will help you.

Upvotes: 0

Leo
Leo

Reputation: 1046

One reason why android may try to scale your images is if you don't have them ready for your screen density. Make sure that you have your png image in res/drawable-xxhdpi, res/drawable-xhdpi, res/drawable-mdpi - all screen densities you are planning to support.

Note that xxhdpi is not mentioned in android documentation and the folder is not created by default but you need it if you are planning to support xxhdpi screens.

Upvotes: 0

Shayan Pourvatan
Shayan Pourvatan

Reputation: 11948

you can use following code to have circle image:

add this on drawable folder

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="oval">
    <solid android:color="#2085c226"/>
    <stroke android:width="2sp" android:color="#85c226" />
</shape>

then in your code

android:background="@drawable/name_of_xmlfile"

Upvotes: 1

Related Questions