Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
361 views
in Technique[技术] by (71.8m points)

android - 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.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

2.1m questions

2.1m answers

60 comments

56.8k users

...