android shape使用
24072 ワード
shapeはandroid開発において特に重要ではなく,shapeを用いなくてもshapeを用いる効果が得られる.しかしshapeの使用には多くの利点があります.1.app痩身、shape定義の資源はUI設計の画像資源よりはるかに小さく、現在は携帯電話に記憶空間が不足していないが、小さくてインタフェースが豊富なアプリケーションを作ることができ、これはユーザーの流量を節約し、ネット上の流通を強化し、ユーザーのソフトウェアダウンロードの心理的な圧力を減らすのに役立つかもしれない.2.ソフトウェア開発のスピードを速め、チームコミュニケーションの効率損失を減らす.これにより、ソフトウェア開発者は、自分の角度からソフトウェアのインタフェースをより自由かつ迅速に調整することができ、いくつかの文字を修正するのにかかる時間は、1枚の画像を作成して置き換える時間よりもはるかに小さく、UIのためにいくつかの微小な色の変化がソフトウェアに与える影響を適切に説明することは非常に困難である.スクリーンサイズと解像度が変化する場合,shapeの利点はかなり明らかである.3.androidのオープンソース特性のため、画像のリソースのアイデアは他の人に取得されやすく、模倣されやすい.多くのアプリケーションがshapeを使用しているが、扁平化されたUIの世界では、shapeの優位性がより明らかになるかもしれない.一部のインタフェースが友好的で反コンパイラに成功できない場合、彼の画像を分析して関連技術の詳細を知ることは可能であるが、shapeを使用すると、研究者が非常に落胆する可能性があり、利用可能なリソースの画像さえ見えない.
1、android:radius、丸み半
直径は、下の単一角度半径アトリビュートで上書きされます.デフォルトは1 dpで、値が大きいほど丸く見えます.
<?xml version="1.0" encoding="utf-8"?>
<shape
xmlns:android="http://schemas.android.com/apk/res/android"
android:shape=["rectangle" | "oval" | "line" | "ring"] > --- rectangle
<corners -- shape=“rectangle” ,
android:radius="integer" -- , , 1dp,
android:topLeftRadius="integer"
android:topRightRadius="integer"
android:bottomLeftRadius="integer"
android:bottomRightRadius="integer" />
<gradient --
android:angle="integer"
android:centerX="integer"
android:centerY="integer"
android:centerColor="integer"
android:endColor="color"
android:gradientRadius="integer"
android:startColor="color"
android:type=["linear" | "radial" | "sweep"]
android:useLevel=["true" | "false"] />
<padding
android:left="integer"
android:top="integer"
android:right="integer"
android:bottom="integer" />
<size -- , imageview scaleType 。
android:width="integer"
android:height="integer" />
<solid -- , 。( , OK)
android:color="color" />
<stroke -- ,border,dashWidth dashGap 0dp
android:width="integer"
android:color="color"
android:dashWidth="integer" --
android:dashGap="integer" /> --
</shape>
1、android:radius、丸み半
直径は、下の単一角度半径アトリビュートで上書きされます.デフォルトは1 dpで、値が大きいほど丸く見えます.
2、 , , ,eclipse graphics preview 。 。( , )
<size>
gradient
solid: りつぶしとは、 りつぶしを し、 りつぶした が を じる です.
Android:color りつぶしの を する
gradient:グラデーション
Android:startColorとandroid:endColorはそれぞれ と で、ndroid:angleはグラデーション で、
45の でなければなりません.
また、ランプのデフォルトモードはandroid:type=「linear」、すなわち ランプです.ランプをラジアルランプ、android:type=「radial」と できます.ラジアルランプには android:gradientRadius=「50」を する があります.sweepは
グラデーション、 で、 のようで、 で 1 0 から360 の
stroke: , ,
android:width="2dp" ,android:color 。
, :
android:dashWidth="5dp"
android:dashGap="3dp"
android:dashWidth '-' ,android:dashGap 。
padding
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" >
<!-- -->
<solid
android:color="#B2B2B2"
/>
<!-- -->
<size
android:width="200dp"
android:height="50dp"
/>
<!-- -->
<gradient
android:startColor="#DBDCDD"
android:endColor="#B8B9BB"
android:centerColor="#ADADAF"
android:angle="270"
/>
<!-- -->
<stroke
android:width="2dp"
android:color="#3D4148"
/>
<!-- -->
<corners
android:radius="5dp"
/>
<padding
android:left="10dp"
android:top="10dp"
android:right="10dp"
android:bottom="10dp"
/>
</shape>
<!--
1、 solid
:
android:color
2、size
:size:
:
android:width
android:height
3、gradient
:
:
android:startColor
android:endColor
android:angle (PS: angle=0 , 。 , angle=90 。angle 45 )
android:type ( :linear、radial、sweep)
linear ,
radial , 。
sweep 。
android:centerColor ,
android:useLevel LevelListDrawable , true。 true 。false
android:gradientRadius . android:type="radial" 。 android:type="radial" 。
android:centerX X
android:centerY Y
4、stroke
: stroke: html border
:
android:width
android:color
android:dashWidth ,
0 , 。 0 。
android:dashGap , “ - - - - ”
5、corners
: corners:
:
android:radius
android:topLeftRadius
android:topRightRadius
:
android:bottomLeftRadius
android:bottomRightRadius
6、padding
: ,
:
android:left
android:top
android:right
android:bottom
-->
:
http://blog.csdn.net/rflyee/article/details/20785495
http://blog.csdn.net/chengyingzhilian/article/details/7340858
http://tech.ddvip.com/2012-10/1351226528184208.html