Skip to content

Instantly share code, notes, and snippets.

@dagezi
Last active December 8, 2015 02:51
Show Gist options
  • Save dagezi/72ea623f0d35932cc573 to your computer and use it in GitHub Desktop.
Save dagezi/72ea623f0d35932cc573 to your computer and use it in GitHub Desktop.
9patchの異常な仕様、あるいはなぜ私はドットを打つのをやめて scriptを書くようになったか ref: http://qiita.com/dagezi/items/be73212e12fea1e4e545
ninepatch {
round_rect {
vStretch 8, 32
hStretch 8, -8
vPadding 7, 33
hPadding 7, -7
}
}
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'io.github.dagezi.ninepatch:plugin:0.0.2'
}
}
apply plugin: 'io.github.dagezi.ninepatch'
ninepatch {
round_rect { // 通常、これが対象となる PNGファイル名
// 座標はすべて dp指定。mdpiの PNGの座標と思っておけばいい
vStretch 8, 32 // 8行から 31行目が伸びる。end exclusive
hStretch 8, -8 // 負の値は終わりからの距離を示す
vPadding 7, 33 // NG: hdpiでの誤差を考えると偶数にすべき
hPadding 7, -7
}
balloon {
// 複数のファイルを `src` で指定する同じ設定を適用できる
// その場合、closure先頭のファイル名は無視される
src 'balloon'
src 'balloon_red'
// 一方向に複数の stretch領域を指定できる
// 領域の長さによって伸びやすさを指定できる
// この例では、吹き出しの下の部分は上の部分より 2倍伸びるので、
// 常に突端が上側につく。
vStretch 10, 12
vStretch 30, 34
hStretch 12, 32
vPadding 8, -8
hPadding 10, -8
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment