九补丁不需要的图像绵延闪屏 [英] Unwanted stretching of nine-patch image for splash screen
问题描述
我想用一个九宫格图像,使其闪屏为我的应用程序,它应该是相同的(平方)在纵向和横向方向。
我的code是简单的:
公共无效的onCreate(捆绑冰柱){
super.onCreate(冰柱);
的setContentView(R.layout.splashscreen);
//更多code这里...
}
我的资源文件是:
<?XML版本=1.0编码=UTF-8&GT?;
<层列表的xmlns:机器人=http://schemas.android.com/apk/res/android>
<项目>
<位图的android:SRC =@绘制/ launch_image/>
< /项目>
< /层列表>
九宫图像看起来罚款,绘制9补丁程序:
但作为结果的图像被拉伸:
有什么不对?可以九宫格图像在所有使用这种方式?
解决方案
由于9修补程序,目的是要伸展。结果 您最好使用一个正方形图片,并把它作为一个 参考:<一href=\"http://developer.android.com/reference/android/widget/ImageView.ScaleType.html\">http://developer.android.com/reference/android/widget/ImageView.ScaleType.html I want to use a nine-patch image to make a splash screen for my application, which should look the same (square) in both portrait and landscape orientation. My code is simple: My resource file is: Nine-patch image looks fine in Draw 9-patch utility:
But as the result the image is stretched:
What's wrong? Can nine-patch images be used this way at all? Because 9 patches are meant to be stretchable. You'd better use a square image and use it as a Reference: http://developer.android.com/reference/android/widget/ImageView.ScaleType.html 这篇关于九补丁不需要的图像绵延闪屏的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋! CAN九宫图像在所有使用这种方法
一个很好的教程:<一href=\"http://radleymarx.com/blog/simple-guide-to-9-patch/\">http://radleymarx.com/blog/simple-guide-to-9-patch/源
(的android:SRC
),不作为背景(的android:背景
)为您的ImageView的结果。
然后,你可以通过设置安卓ajust它:(?
属性。 FIT_XY
)scaleType public void onCreate(Bundle icicle) {
super.onCreate(icicle);
setContentView(R.layout.splashscreen);
// more code here...
}
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >
<item>
<bitmap android:src="@drawable/launch_image" />
</item>
</layer-list>
Can nine-patch image be used this way at all?
Well, no. Not properly.
A nice tutorial: http://radleymarx.com/blog/simple-guide-to-9-patch/source
(android:src
), not as a background (android:background
) for your ImageView.
Then you can ajust it by setting the android:scaleType
attribute (FIT_XY
?).