简体   繁体   中英

rounded view's corners android, NOT round background

I know how to give round borders using XML in Android. I thought it would be cool to make the radius of one corner of my textView excessively large. The problem is, the text keep spilling out. Can I make my textview have a TRULY round corner? (Not just the background). If this was CSS this would be so easy. I am new to Android.

So in terms of CSS, I want to set my overflow to hidden so to speak.

Please help me.

In short, no. All Views are rectangular and fit in bounding boxes.

The best way to achieve rounded corners is the way you mention; using a shape drawable with corner radius set as the background to your TextView.

Like ataulm said, all Views are rectangular.

Create a shape drawable allows you to create a background with rounded corners. You'd have to use padding to make sure the text doesn't clip in certain areas.

<?xml version="1.0" encoding="UTF-8"?> 
<shape xmlns:android="http://schemas.android.com/apk/res/android"> 
    <solid android:color="#ffffffff"/>    

    <stroke android:width="4dp"
        android:color="#ff0000"/>

    <padding android:left="4dp"
         android:top="4dp"
         android:right="4dp"
         android:bottom="4dp"/> 

    <corners android:bottomRightRadius="7dp" 
             android:bottomLeftRadius="7dp" 
             android:topLeftRadius="7dp" 
             android:topRightRadius="7dp"/> 
</shape>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM