2016-06-24 7 views
0

誰でも私に幾分長方形の形を作成する方法を教えてもらえますが、最後は三角形です。プログラムでそれをやって画像のようにアンドロイドで図形を作成する方法は?

enter image description here

+1

: あなたはその後、私はこのコードを使用しsearchicon.pngと

をarrow.pngアイコンと同様に行うことができます。アセットを使用する必要があります。 – basilisk

+0

しかし、アセットを使用すると、このような効果を与えることはできません。 –

+2

すべてのエフェクトをアセット自体に組み込むことができます。 – basilisk

答えて

2

私はあなたの描画可能なフォルダを持っている勾配画像を使用します。それをbackground.pngと呼んでみましょう。私はあなたがプログラムによってこの形を作ることができるとは思わない

<RelativeLayout 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:padding="10dp" 
    android:background="@drawable/background"> 
    <LinearLayout 
     android:layout_width="wrap_content" 
     android:layout_height="match_parent" 
     android:orientation="vertical" 
     android:layout_alignParentLeft="true" 
     android:layout_alignParentStart="true" 
     android:gravity="center_vertical"> 
     <TextView 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:textColor="#ffffff" 
      android:layout_marginBottom="10dp" 
      android:text="Current Location"/> 
     <LinearLayout 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:orientation="horizontal"> 
      <TextView 
       android:layout_width="wrap_content" 
       android:layout_height="match_parent" 
       android:textColor="#ffffff" 
       android:textSize="20dp" 
       android:text="Mumbai"/> 
      <ImageView 
       android:layout_width="20dp" 
       android:layout_height="20dp" 
       android:layout_marginLeft="20dp" 
       android:layout_marginStart="20dp" 
       android:src="@drawable/arrow"/> 
     </LinearLayout> 
    </LinearLayout> 
    <ImageView 
     android:layout_width="50dp" 
     android:layout_height="50dp" 
     android:layout_marginRight="50dp" 
     android:layout_marginEnd="50dp" 
     android:layout_centerVertical="true" 
     android:layout_alignParentRight="true" 
     android:layout_alignParentEnd="true" 
     android:src="@drawable/searchicon"/> 
</RelativeLayout> 
0

その良くないアプローチあなたはXMLのデザインを使用して結果を取得乗り切ります。

enter image description here

関連する問題