16

我想对文本视图的唯一一侧进行舍入,例如从左上角开始,从右上角开始一轮,我使用此代码。但它不起作用。

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" >

<solid android:color="@color/login_layout" />

<stroke
        android:width="1dp"
        android:color="@color/login_layout" />

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

<corners
        android:bottomLeftRadius="0dip"
        android:bottomRightRadius="0dip"
        android:topLeftRadius="10dip"
        android:topRightRadius="10dip" />

</shape>
4

5 回答 5

8

有时它不会在模拟器和图形布局中显示尝试在真实设备中运行代码并检查

于 2012-10-09T04:57:39.243 回答
8

请尝试这种方式..

texttextshape.xml 文件。

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"

    android:shape="rectangle" >

    <solid android:color="#FFFFFF" />
    <corners
        android:bottomLeftRadius="5dp"
        android:bottomRightRadius="5dp"
        android:topLeftRadius="5dp"
        android:topRightRadius="5dp"
         />

</shape>

并设置 Text_view android:background="@drawable/texttextshape"

我觉得对你有帮助。。

于 2012-10-09T04:59:17.593 回答
5

Change,

<corners
    android:bottomLeftRadius="0dip"
    android:bottomRightRadius="0dip"
    android:topLeftRadius="10dip"
    android:topRightRadius="10dip" />

to

<corners
    android:radius="5dip"
    android:bottomLeftRadius="0dip"
    android:bottomRightRadius="0dip"
    android:topLeftRadius="10dip"
    android:topRightRadius="10dip" />

Actually this is a bug in android and you have to manually set the radius attribute to some random value explicitly before applying other radius values.

于 2012-10-09T05:05:03.163 回答
2

最简单的解决方案是制作一个圆角的图像并将其设置为 textView 的背景。

于 2012-10-09T06:01:46.150 回答
1

make one xml in drawable folder.. suppose round.xml . Then edit it as below..

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

        android:color="#ffffff"
        />
    <corners 
        android:topLeftRadius="15px" 
        android:bottomLeftRadius="15px"
        />

     <padding
     android:top="3dp"
     android:bottom="3dp"
     />
</shape>

Then in background of textview set this xml.

于 2012-10-09T05:03:21.443 回答