Skip to content

Instantly share code, notes, and snippets.

@mstssk
Last active December 10, 2015 05:48
Show Gist options
  • Save mstssk/4389836 to your computer and use it in GitHub Desktop.
Save mstssk/4389836 to your computer and use it in GitHub Desktop.
最も外側のitem要素を基準にしたpaddingによる相対的なサイズ・位置の指定。 https://gist.github.com/4328658 からドロイド君の胴体部分と外枠部分の記述だけを抜き出したもの。
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >
... 胴体の下に置きたい要素 ...
<!-- body(ドロイド君の胴体): 外枠からのtop,bottom,left,rightを記述して位置・大きさを指定 -->
<item
android:bottom="82dp"
android:left="60dp"
android:right="60dp"
android:top="136dp">
<shape android:shape="rectangle" >
<solid android:color="@color/android" />
<stroke
android:width="10dp"
android:color="@android:color/white" />
<corners
android:bottomLeftRadius="22dp"
android:bottomRightRadius="22dp" />
<!-- top,bottom,left,rightが優先されるらしく、ここではsizeは意味がない -->
</shape>
</item>
... 胴体の上に置きたい要素 ...
<!-- base(外枠のための要素): sizeを指定して外枠を定義 -->
<item>
<shape android:shape="rectangle" >
<solid android:color="@android:color/transparent" />
<size
android:height="422dp"
android:width="360dp" />
</shape>
</item>
</layer-list>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment