androidandroid-studioicons

How do I change the size of icons in Android Studio?


I'm building an app with Android Studio, and one of my activities (which lets the user draw on a canvas) has a 'toolbar', with things like 'Clear', 'Undo', 'Redo' etc.

I'm using the built-in icons for this - ie I go to the 'Drawables' folder, right-click, go to 'Add vector asset' and then select the appropriate icon. I've figured out that I can change the size of the icon that gets added, but I can't figure out how to use that.

So, on a phone screen, I'd like to use the standard 24dp icons. However, on a tablet screen, I'd like the icon to be bigger, as they're a bit lost on the bigger screen.

I can't figure out how to do this, though, and I'm not even sure whether I'm using the right approach. I know I can create different drawables sub-folders for different densities, but it's not so much the density that matters as the actual screen size.

How can I achieve this?


Solution

  • Go to the XML side of the designer. Find the image you are trying to increase the size of. Set the constraints according to the size you want and then include:

    android:scaleType="fitCenter"
    

    There are other values available, but this will increase the size of the image to the maximum possible without cropping while keeping it centered in the view.