2017-03-30 17 views
-3

Androidでこの種の背景を作成するにはどうすればよいですか?私はこれをどうやって行うのか分かりません。 Android - このレイアウトの背景を作成する方法(画像内部)

enter image description here

この

は、私が試したものです

triangle.xml

<layer-list xmlns:android="http://schemas.android.com/apk/res/android"> 
<item> 
    <rotate 
     android:fromDegrees="-77" 
     android:pivotX="0" 
     android:pivotY="0" 
     android:toDegrees="0"> 
     <shape android:shape="rectangle"> 
      <solid android:color="@color/colorPrimary" /> 
     </shape> 
    </rotate> 
</item> 
</layer-list> 

layout.xml

<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
xmlns:tools="http://schemas.android.com/tools" 
android:layout_width="match_parent" 
android:layout_height="match_parent" 
tools:context="br.com.fornaro.armariovirtual.AccountCreatedActivity"> 

<View 
    android:id="@+id/background" 
    android:layout_width="match_parent" 
    android:layout_height="300dp" 
    android:background="@color/colorPrimary" 
    android:elevation="@dimen/elevation" /> 

<View 
    android:id="@+id/view" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:layout_below="@id/background" 
    android:background="@drawable/triangle" 
    android:elevation="@dimen/elevation" /> 

<TextView 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_above="@+id/view" 
    android:layout_centerHorizontal="true" 
    android:elevation="@dimen/elevation" 
    android:gravity="center" 
    android:text="@string/account_created" 
    android:textColor="@android:color/white" 
    android:textSize="30sp" /> 

<Button 
    style="@style/Widget.AppCompat.Button.Borderless" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_alignParentBottom="true" 
    android:layout_alignParentEnd="true" 
    android:layout_alignParentRight="true" 
    android:layout_marginBottom="16dp" 
    android:layout_marginEnd="16dp" 
    android:layout_marginRight="16dp" 
    android:drawableEnd="@android:drawable/ic_media_play" 
    android:drawableRight="@android:drawable/ic_media_play" 
    android:drawableTint="@color/colorPrimary" 
    android:text="@string/continue_label" 
    android:textColor="@color/colorPrimary" 
    android:textStyle="bold" /> 

</RelativeLayout> 

結果は次のとおりです。 enter image description here

この三角形の修正方法は?または、このレイアウトをより良い方法で使用しますか?

答えて

0

PaintまたはPhotoShopを使用するのが最も簡単です。

+0

実際には、この種のレイアウトを使用する別の画面があるので、これはコードが必要です:(このため、この三角形を描く必要があります) –

+0

あなたはそれを背景イメージにできませんか? – JediBurrell

+0

どういう意味ですか?画像? –

関連する問題