4

Is it possible to define a shape like shown on the following image:

rectangle ending in a circle

I tried a layer-list but I could not find a solution close to what I am looking for.

I want to use the resulting shape as a background image to a RelativeLayout with a transparency.

Any hints are appreciated! Thank you.

Onik
  • 19,396
  • 14
  • 68
  • 91
OpenHaus
  • 97
  • 2
  • 9
  • 17

1 Answers1

4

Here is the shape you asked for:

<?xml version="1.0" encoding="UTF-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >
<item>
    <shape android:shape="rectangle">
        <size 
            android:width="250dp"
            android:height="100dp" />
        <solid android:color="#ffffff" />
    </shape>
</item>

<item
    android:top="0dp">
    <shape android:shape="line">
        <stroke
            android:width="25dp"
            android:color="#000000" />
    </shape>
</item>

<item
    android:right="0dp"
    android:left="150dp">
    <shape android:shape="oval">
        <solid android:color="#000000" />
    </shape>
</item>
</layer-list>

Screenshot:

enter image description here

Onik
  • 19,396
  • 14
  • 68
  • 91
  • This has partly solved my problem. The part with the transparency does not work correctly with your solution. Also scaling is a hassle. I will give you credit for your answer. – OpenHaus Oct 17 '14 at 08:32
  • @OpenHaus I haven't tested the shape with transparent background instead of white one. You can try... Regarding scaling, I agree, once you change the size of the container rectangle (the white one) you may need to adjust the rest of shape's sizes. Even though shape drawables is automatically scaled for different densities, you might consider using different dimension values under the `res/values` folder for your shapes. – Onik Oct 17 '14 at 10:16