2013-01-17 29 views

回答

1

作秀像上面的輸出圖像

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:background="#eeeeee" 
    android:orientation="horizontal" > 

    <TextView 
     android:id="@+id/textView1" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:text="E" 
     android:paddingTop="5dp" 
     android:paddingBottom="5dp" 
     android:paddingLeft="15dp" 
     android:paddingRight="15dp" 
     android:background="@android:color/white" 
     android:layout_marginRight="5dp" /> 
     <TextView 
     android:id="@+id/textView2" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:text="F" 
     android:paddingTop="5dp" 
     android:paddingBottom="5dp" 
     android:paddingLeft="15dp" 
     android:paddingRight="15dp" 
     android:background="@android:color/white" 
     android:layout_marginRight="5dp" /> 

</LinearLayout> 
+0

非常非常感謝你的人,你是輝煌 –

+0

我有這樣的新問題http://stackoverflow.com/questions/14539670/i-want-to-make-separator-like-the-following –

0

我覺得你可以的把三Views與顏色實現這一點,你要

<View 
android:layout_height="wrap_content" 
android:layout_width="1dip" 
android:background="#f3f3f3" 
/> 
+0

layout_height = 「match_parent」,但除此之外,我同意。 ImageView更多功能;但如果你不想要任何花哨的東西,這個輕巧簡單。 –

+0

但我有Android:layout_width =「0px」 android:layout_weight =「1」使所有視圖具有相同的空間量 –

+0

@forsubhi不要把這個視圖的任何重量我已經試過它與我的代碼工作得很好。 – amDroid

3

如果你想要一個自定義分隔符,請使用separ ator.xml在繪製

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

    <gradient 
     android:angle="90" 
     android:centerColor="#ffffffff" 
     android:endColor="#00ffffff" 
     android:startColor="#00ffffff" /> 

</shape> 

然後參考該分離器形狀與此

<ImageView 
    android:id="@+id/imageView1" 
    android:layout_width="2dip" 
    android:layout_height="fill_parent" 
    android:layout_marginLeft="4dip" 
    android:layout_marginRight="4dip" 
    android:src="@drawable/seperator" /> 

結果:

​​

enter image description here

0

要創建的Android,我們的邊界必須在形狀中使用中風標籤(xml繪製)

這裏是我的代碼,我在我的結束已經測試:

stroke_background.xml

<stroke android:width="1dp" 
     android:color="@android:color/darker_gray"/> 
    <solid android:color="#ffffff"/> 


</shape> 

佈局您需要

<LinearLayout 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:layout_marginTop="20dp" 
    android:weightSum="1"> 

    <LinearLayout 
     android:layout_width="0dp" 
     android:layout_height="match_parent" 
     android:orientation="vertical" 
     android:layout_weight=".5" 
     android:background="@drawable/stroke_background"> 

     <TextView 
      android:id="@+id/textView1" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:gravity="center" 
      android:text="E" /> 

    </LinearLayout> 

    <LinearLayout 
     android:layout_width="0dp" 
     android:layout_height="match_parent" 
     android:orientation="vertical" 

     android:background="@drawable/stroke_background" 
     android:layout_weight=".5" 
     > 

     <TextView 
      android:id="@+id/textView2" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:gravity="center" 
      android:text="F" /> 

    </LinearLayout> 

</LinearLayout> 

結果是這樣的.. enter image description here