2017-09-29 10 views
0

Activityの背景を2色にすることを検討しています。上のカスタムカラーと下のホワイトカラー。物事は私は水平線でそれらを分離したくないということです。私は提供されたイメージに非常に類似したものを作りたいと思います。私は本当に私はこれを試してみましたが、再び、私は本当に水平分離を持っている必要はありません...どここれを作成するために開始するAndroidのアクティビティでマルチカラーの背景を作成する方法

enter image description here

を知ることはできません。私はより多くのイメージのような分離を好むだろう。

これまで私が試したことは次のとおりです。

<?xml version="1.0" encoding="UTF-8"?> 
<layer-list xmlns:android="http://schemas.android.com/apk/res/android"> 
    <item> 
     <shape android:shape="rectangle"> 
      <solid android:color="#FAFAFA" /> 
     </shape> 
    </item> 
    <item android:bottom="300dp" android:top="0dp" android:left="0dp" android:right="0dp"> 
     <shape android:shape="rectangle"> 
      <solid android:color="@color/colorPrimary" /> 
     </shape> 
    </item> 
</layer-list> 
+0

..私がきたもの https://developer.android.com/guide/topics/graphics/vector-drawable-resources.html 過去に行われたのは、svgイメージを作成して変換することだけでした。 –

答えて

1

レイアウトの背景として、このようなものが必要です。

<?xml version="1.0" encoding="utf-8"?> 
<vector xmlns:android="http://schemas.android.com/apk/res/android" 
    android:width="100dp" 
    android:height="100dp" 
    android:viewportHeight="100" 
    android:viewportWidth="100"> 
    <path 
     android:fillColor="@color/colorPrimary" 
     android:pathData="M0,0 L0,50 L500,80 L500,0 z" /> 
</vector> 

これは私のエミュレータでは次のようになります。私はあなたがベクトルドローアブルを使用して、より良い運を持っているかもしれないと思う

enter image description here

関連する問題