tags:

views:

303

answers:

1

Is it possible to create an Android shape object with stroke on only certain sides?

Eg I have:

<stroke 
 android:width="3dip" 
 android:color="#000000"
    android:dashWidth="10dip" 
    android:dashGap="6dip" />

Which is similar to this CSS:

border: 3px dashed black;

How can I set the stroke on just one side? This is how I would do it in CSS:

border-left: 3px dashed black;

How do you do this in Android XML?

A: 

I solved this by using a list-layer, combining two shapes, one of which with height 1dp placed at the bottom

optionscreen_bottomrectangle.xml:

<layer-list>
<item>
      <shape>
            <solid android:color="#535353">
      </shape>
</item>
<item android:bottom="1dp">
     <shape>
           <solid android:color="#252525"
     </shape>
</item>
</layer-list>

Then, in the layout/main.xml file

<TextView
    android:id="@+id/bottom_rectangle"
    android:background="@drawable/optionscreen_bottomrectangle"
    android:layout_width="fill_parent"
    android:layout_height="0dp"
    android:layout_below="@id/table_options"
    android:layout_above="@id/exit_bar"/>

Which fills the gap between table_options and exit_bar with a background and just before exit_bar prints a 1dp line. This did the trick for me, I hope it helps someone else.

Maragues
It might be handy not to post an answer if you really want to have an answer yourself. When other devs see there's already an answer (altough in this case it's actually non) they are not as inclined to answer.
MrSnowflake
you're right, sorry about that. How am I suposed to refloat a question?
Maragues
I edited the answer with useful information.
Maragues