2016-04-05 28 views
1

Yani, yalnızca bir tarafı olan bir şekil (dikdörtgen) oluşturmayı başardım. Şimdi, bir tarafın kenar boşluğu ve kenar boşluğu olmasını istiyorum.Kenar boşluklu Android çizim çizgileri

Right now it looks like this:

ve (renkleri umursamıyorum) gibi bakmak gerekiyordu nasıl: Şu anda böyle görünüyor

Şimdi enter image description here

, bir kod için sahip satır:

<layer-list xmlns:android="http://schemas.android.com/apk/res/android" > 

<item 
    android:left="-55dp" 
    android:right="-55dp" 
    android:top="-55dp"> 
    <shape android:shape="rectangle" > 
     <solid android:color="@android:color/transparent" /> 

     <stroke 
      android:width="5dp" 
      android:color="@color/text" /> 
    </shape> 
</item> 

Bunu nasıl başarabilirim?

Metin görünümleri için düzen.

<LinearLayout 
     android:id="@+id/picture_activity_linear" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:layout_marginBottom="@dimen/layout_margin" 
     android:layout_marginLeft="@dimen/layout_margin" 
     android:layout_marginRight="@dimen/layout_margin" 
     android:background="@color/background" 
     android:orientation="vertical" 
     android:visibility="visible"> 


     <TextView 
      android:id="@+id/picture_activity_take_new" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:background="@drawable/shape_text_line" 
      android:drawableStart="@drawable/ic_profilepicture_takephoto" 
      android:gravity="center" 
      android:padding="@dimen/layout_padding" 
      android:text="Take a new picture" 
      android:textColor="@color/text" 
      android:textSize="@dimen/large_text_size"/> 

     <TextView 
      android:id="@+id/picture_activity_select_from_gallery" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:drawableStart="@drawable/ic_profilepicture_addphoto" 
      android:gravity="center" 
      android:padding="@dimen/layout_padding" 
      android:text="Select new from gallery" 
      android:textColor="@color/text" 
      android:textSize="@dimen/large_text_size"/> 


     <TextView 
      android:id="@+id/picture_activity_remove_photo" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:drawableStart="@drawable/ic_profilepicture_delete" 
      android:gravity="center" 
      android:padding="@dimen/layout_padding" 
      android:text="Remove photo" 
      android:textColor="@color/text" 
      android:textSize="@dimen/large_text_size"/> 


    </LinearLayout> 
+0

istediği gibi

if(position == itemList.length - 1){ //position starts from 0 holder.line.setVisibility(View.GONE); } 

Şimdi bu bakacağız? –

+0

height = 1dp, 2dp ile bir görünüm yapın –

cevap

1

Bence bir recyclerview kullanıyorsunuz. Bir geri dönüşüm için, tek bir sıra düzenine sahip olmanız gerekir.

<LinearLayout> 
    height, width, id 

    <TextView> 
     width = "match_parent" 
     height, id 

    <LinearLayout> 
     android:id="@+id/line" 
     android:height="2dp" 
     android:width="match_parent" 
     android:layout_marginLeft="whatever_you_need" 
     android:layout_marginRight="whatever_you_need" 
     android:background="some_color" /> 

</LinearLayout> 

Dolayısıyla, burada satır eklemeniz gerekmez elle her bir sorun vardır, yani hat son satırın altına gelecek. Onu kaldırmak istediğine inanıyorum. recyclerview adaptörü içinde viewholder sınıfında adaptör

String[] itemList = {"Take a new Picture", "Select from Gallery",...}; 

yılında

:

line = (LinearLayout) itemView.findViewById(R.id.line); 

recyclerview için onBindViewHolder olarak. Burada son satırı tespit edip alt çizgiyi gizliyoruz. Eğer şekil Burada gereklidir neden

+0

Hayır, bunlar kodlanmış öğelerdir. –

+0

recyclerview, esnek ve tüm + daha fazla işlevselliğe sahip olduğu için size daha iyi hizmet sunacaktır ... eğer hala sabit kodlu yapmak istiyorsanız, çözümün hala linelaylayışı olan kısmı hala bekletir, tekrar istediğiniz kadar tekrarlayın – suku