use programmatically linear Radius corner, modifying circuference only on one side

Asked

Viewed 41 times

-2

Modifica apenas um lado de uma linear

use Radius corner programmatically in a linear, modifying only the circuference of two sides

1 answer

1

Create a Drawable to make the shape of the corner, with the name corner.xml, as below:

<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle">
    <stroke 
         android:width="2dp" 
         android:color="#FF0000">
    </stroke>
    <solid 
        android:color="#FFFF00">
    </solid>
    <corners 
         android:topLeftRadius="5dp"
         android:topRightRadius="0dp"
         android:bottomLeftRadius="5dp"
         android:bottomRightRadius="0dp">
    </corners>
</shape>

After that enter the same as your background LinearLayout, as below:

<LinearLayout 
    android:id="@+id/linearLayout"
    android:layout_width="200dp"
    android:layout_height="100dp"
    android:gravity="center"
    android:layout_centerInParent="true"
    android:background="@drawable/corner">
 </LinearLayout>

Browser other questions tagged

You are not signed in. Login or sign up in order to post.