水平缩放NinePatch图像(无子,在RelativeLayout的) [英] Scaling NinePatch image horizontally (without children, in a RelativeLayout)

查看:102
本文介绍了水平缩放NinePatch图像(无子,在RelativeLayout的)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图用一个形象NinePatch,横向拉长。

I'm trying to use a NinePatch image, stretched horizontally.

我没有用太多NinePatch,但在其他方面工作的其他NinePatches图像(例如,作为与内容的看法的背景),符合市场预期。

I haven't used NinePatch much, but do have other NinePatches images working in other areas (e.g., as background of of Views with content), as expected.

我已经附加了什么我遇到的简化版本。基本上我想要的网点平铺中心像素水平。该图像将只水平扩展。它不包含任何其他意见。

I've attached a simplified version of what I'm experiencing. Basically I want the dot to tile the center pixel horizontally. The image will only ever expand horizontally. It does not contain any other views.

我第一次尝试设置只是一个单一像素的垂直路径,然后加一个单像素水平的路径为好。没有不同。在NinePatch工具的preVIEW面板,看起来很好。

I first tried setting just a single-pixel vertical path, then added a single-pixel horizontal path as well. No difference. In the preview panel of the NinePatch tool, it appears fine.

这是在一个RelativeLayout的被使用,每低于code样品。我已经包含了被注释掉,因为我已经尝试过其他的设置行。

It's being used in a RelativeLayout, per the code sample below. I've included lines that are commented out as other settings I've tried.

track = new ImageView(context);
track.setScaleType(ScaleType.FIT_XY);
//track.setScaleType(ScaleType.FIT_CENTER);
track.setBackgroundResource(R.drawable.bg_track);
//track.setImageResource(R.drawable.bg_track);

LayoutParams trackLayout = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
//LayoutParams trackLayout = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
trackLayout.addRule(RelativeLayout.CENTER_VERTICAL);
trackLayout.addRule(RelativeLayout.ALIGN_PARENT_LEFT);
trackLayout.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);

addView(track, trackLayout);

我敢肯定,我失去了一些东西简单,但不能看着办吧。

I'm sure I'm missing something simple, but can't figure it out.

任何见解是AP preciated。

Any insights are appreciated.

TYIA。

推荐答案

你误会Ninepatch概念。试图通过这一形象理解

you misunderstood Ninepatch concept. try to understand by this image

您也可以尝试使用此工具BetterNinePatch 的http://机器人。 elex.pe.kr/a-better-9-patch-tool :)

You can also try with this BetterNinePatch tool http://android.elex.pe.kr/a-better-9-patch-tool :)

努力创造这样的。

这篇关于水平缩放NinePatch图像(无子,在RelativeLayout的)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆