Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Creating a rectangle shape with only two rounded edges

Tags:

android

shape

I can create a shape that is a rectangle with all edges rounded. However, what I'm wanting is a rectangle shape with only 2 of the edges rounded. Is this possible?

I'm essentially hacking together a ListView that looks like a bubble with rounded edges. I'm looking to add a header that has the two top edges rounded and a footer with the two bottom edges rounded.

like image 353
Andrew Avatar asked Oct 14 '10 15:10

Andrew


People also ask

What is a rectangle with 2 rounded corners called?

Microsoft calls it a Round diagonal corner rectangle. Here are the names of various rectangles (one can confirm this for oneself by mouse-hovering over these shapes in e.g. Powerpoint or Word): Follow this answer to receive notifications. edited Sep 12, 2018 at 20:52.

What is a rectangle with rounded edges?

A rounded rectangle is the shape obtained by taking the convex hull of four equal circles of radius and placing their centers at the four corners of a rectangle with side lengths and . A filled rounded rectangle with (or. ) is called a stadium.

Can a rectangle have rounded sides?

Definition of ROUNDED CORNER RECTANGLES:Labels that are rectangular in shape and have rounded corners; the corners do not form a sharp point, but instead are curved into an arc.


2 Answers

<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle" android:padding="10dp"> <solid android:color="#FFFFFF"/> <corners  android:bottomRightRadius="0dp" android:bottomLeftRadius="0dp" android:topLeftRadius="15dp" android:topRightRadius="15dp"/> </shape> 

This code is just working (since?) Android version 2.2. Referring to the documentation, the code should look like the following:

<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle" android:padding="10dp"> <solid android:color="#FFFFFF"/> <corners  android:radius="2dp" android:bottomRightRadius="0dp" android:bottomLeftRadius="0dp" android:topLeftRadius="15dp" android:topRightRadius="15dp"/> </shape> 
like image 81
marnaish Avatar answered Sep 19 '22 13:09

marnaish


You might find this helpful.

<?xml version="1.0" encoding="utf-8"?>
<!--  res/drawable/rounded_edittext.xml -->
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle" android:padding="10dp">
 <solid android:color="#FFFFFF"/>
    <corners
     android:bottomRightRadius="0dp"
     android:bottomLeftRadius="0dp"
  android:topLeftRadius="15dp"
  android:topRightRadius="15dp"/>
</shape>
like image 21
Ganesh Bhat Avatar answered Sep 18 '22 13:09

Ganesh Bhat