2017-06-03 7 views
-1

私はこのような私のビューのためのシェイプを作りたいと思います。Androidでxmlを使用して左右の境界線で下矢印インジケータを作成する方法

enter image description here

XMLでそれをする方法はありますか?カスタムはcustom_shape_down_arrow.xmlを描画可能なさ おかげ

ここ
+0

あなたはそれを必要としていますか? –

+0

9パッチイメージの背景で使用できます。 –

+0

ビューページャーでスライダーを作成したいのですが、選択したタブが別のビューに表示されます。下向きの矢印は有効なビューを示し、残りの行は無効なビューに広がり、xmlで作成します。 – user2817947

答えて

2

<?xml version="1.0" encoding="utf-8"?> 
<layer-list xmlns:android="http://schemas.android.com/apk/res/android"> 

    <!-- Background --> 
    <item> 
     <shape android:shape="rectangle"> 
      <size 
       android:width="250dp" 
       android:height="20dp" /> 
      <solid android:color="#cdcdcd" /> 
     </shape> 
    </item> 

    <!-- Top-Left Line --> 
    <item 
     android:right="150dp" 
     android:bottom="18.7dp"> 
     <shape android:shape="line"> 
      <stroke 
       android:color="#999999" 
       android:width="1dp" /> 
     </shape> 
    </item> 

    <!-- Top-Right Line --> 
    <item 
     android:left="150dp" 
     android:bottom="18.7dp"> 
     <shape android:shape="line"> 
      <stroke 
       android:color="#999999" 
       android:width="1dp" /> 
     </shape> 
    </item> 

    <!-- Left-Diagonal Line --> 
    <item 
     android:right="25dp"> 
     <rotate android:fromDegrees="36"> 
      <shape android:shape="line"> 
       <stroke 
        android:color="#999999" 
        android:width="1dp" /> 
      </shape> 
     </rotate> 
    </item> 

    <!-- Right-Diagonal Line --> 
    <item 
     android:left="27dp"> 
     <rotate android:fromDegrees="322"> 
      <shape android:shape="line"> 
       <stroke 
        android:color="#999999" 
        android:width="1dp" /> 
      </shape> 
     </rotate> 
    </item> 

</layer-list> 

使用します。

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:orientation="vertical" android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:layout_margin="24dp" 
    android:gravity="center_horizontal"> 

    <!-- Custom shape --> 
    <LinearLayout 
     android:id="@+id/layout_custom_shape" 
     android:layout_width="wrap_content" 
     android:layout_height="60dp" 
     android:paddingTop="10dp" 
     android:background="#cdcdcd"> 

     <LinearLayout 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_gravity="center" 
      android:background="@drawable/custom_shape_down_arrow"> 

     </LinearLayout> 
    </LinearLayout> 

</LinearLayout> 

OUTPUT:

enter image description here

これは役に立ちます〜

+0

それは動作します。ありがとう – user2817947

+0

それを知ってうれしい。私の答えが役に立つと思われるなら、それを投票してください。ありがとうございました... – FAT

関連する問題