答えて
Please create a drawable file and put the below code in it.
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >
<item>
<shape android:shape="rectangle" >
<size android:height="20dp" />
<solid android:color="#F66D08" />
</shape>
</item>
<item android:top="50dp">
<shape android:shape="rectangle" >
<gradient android:endColor="#AD1B1D"
android:startColor="#E2360A"
android:angle="270" />
</shape>
</item>
</layer-list>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<LinearLayout
android:gravity="center"
android:background="#F66D08"
android:layout_width="match_parent"
android:layout_height="20dp">
</LinearLayout>
<LinearLayout
android:background="@drawable/introslidergradiant"
android:layout_width="match_parent"
android:layout_height="100dp"></LinearLayout>
</LinearLayout>
そして作成drawble RESがintroslidergradiant.xml名前のファイル:
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<shape>
<gradient
android:angle="90"
android:startColor="#A31720"
android:endColor="#E1350B"
android:type="linear" />
</shape>
</item>
</selector>
<?xml version="1.0" encoding="UTF-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/listview_background_shape">
<stroke android:width="2dp" android:color="#ff207d94" />
<padding android:left="2dp"
android:top="2dp"
android:right="2dp"
android:bottom="2dp" />
<corners android:radius="5dp" />
<solid android:color="#ffffffff" />
</shape>
あなたは内部の新しいXMLファイルを作成することができますdrawableフォルダを作成し、上記のコードを追加して、rectangle.xmlとして保存します。
レイアウト内で使用するには、android:background属性を新しい描画可能な形状に設定します。私たちが定義したシェイプにはディメンションがないため、レイアウトで定義されているViewのディメンションが使用されます。
だから一緒にそれをすべて置く:最後に<View
android:id="@+id/myRectangleView"
android:layout_width="200dp"
android:layout_height="50dp"
android:background="@drawable/rectangle"/>
。この矩形を任意のビューの背景に設定することができますが、ImageViewの場合はandroid:srcを使用します。つまり、ListView、TextViewsなどの背景として長方形を使用できます。
あなたが描画可能
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle" >
<gradient
android:type="linear"
android:startColor="#FFFF820D"
android:endColor="#FFA32815"
android:angle="90"/>
</shape>
次のコードを使用するか、またはあなただけの色を設定し、アンドロイドのオプションを選択して、それはあなたのためにグラデーションを生成します独自のグラデーションhereを生成することができますのXMLファイルを作成する必要が。
層-リストは、この
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<shape android:shape="rectangle">
<size
android:width="40dp"
android:height="40dp" />
<solid android:color="#F86F05" />
</shape>
</item>
<item android:top="10dp">
<shape android:shape="rectangle">
<size
android:width="30dp"
android:height="30dp" />
<solid android:color="#B31F19" />
</shape>
</item>
</layer-list>
そして同じのスクリーンショットを解決するために使用することができます。
あなたの代わりに固体の色のグラデーションをしたい場合は、startColor、endColorと角度を勾配設定する固形変更。
完璧なようです。良いアプローチのために 'gradient'を追加してください –
- 1. Androidの長方形の背景のグラデーション
- 2. 固定長方形の長方形パッキング
- 3. 長方形イベントプログラム
- 4. 長方形
- 5. Pythonの:長方形
- 6. 長方形の幅
- 7. MFCの長方形
- 8. 長方形/楕円形プログラム
- 9. Xcodeの「フレーム長方形」と「レイアウト長方形」
- 10. n個の長方形のn個の長方形をn個の大きな長方形に合わせる
- 11. TreeSet長方形コンパレータ
- 12. 長方形/コンプレックスフロートエラー/パイソン
- 13. JavaFX ActionEvent長方形
- 14. wpf3d長方形ヒットテスト
- 15. Matlab - 長方形関数を使用しないプロット長方形
- 16. Javaの長方形のパック
- 17. 長方形のビューのパーフェクトラウンドコーナー
- 18. 不規則な長方形の形
- 19. androidのシャドーで長い楕円形のボタンを作る方法
- 20. iPhone - 長方形の交差
- 21. 図面の長方形
- 22. 長方形のダイヤモンドHTML&CSS3
- 23. Materializecss長方形のグリッド3x3
- 24. 最大の長方形
- 25. ImageMagickの作成長方形
- 26. 長方形のアニメーション例
- 27. Libgdx長方形の配列
- 28. Androidの長方形グラデーションcenterXが動作しない
- 29. 曲がったエッジを持つAndroidの長方形
- 30. カスタム非長方形ボタン三角形
使用「」 –
SripadRaj