Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

9 Patch image where center is 1:1

I want to create a splash screen on Android with a small logo in the middle, but the logo is streched on larger devices. I thought I could use a 9 patch image, but it seems a 9 patch image works inversed to what I try to reach.

splash logo

This is the logo that has to be in the middle.

9 patch splash logo

This is what I get when I set the image as a 9 patch. The center is stretched out and the corners are intact. I need to opposite. I need a 9 patch that can define a center area that is always displayed in correct 1:1 proportion, and border areas at left, right, top and bottom that can be stretched if the image is smaller than the screen.

How can I do this? With or without 9 patch.

like image 295
Ken Vernaillen Avatar asked Nov 05 '13 14:11

Ken Vernaillen


2 Answers

Here is an example of how you can do this. This is a 9patch, so save it like this: yourname.9.png and don't forget to set android:scaleType="fitXY" on your ImageView

enter image description here

like image 168
Damien R. Avatar answered Oct 28 '22 04:10

Damien R.


You might want to mark 4 strech position See the following X mark, just put a dot instead of them. And use (if not already done) the 9path tool inside the SDK folder to have a preview of what will be generated by Android SDK

    X       X
  ************
X ************
  ************
  ****LOGO****
  ************
X ************
  ************
like image 22
azerto00 Avatar answered Oct 28 '22 02:10

azerto00