TextView边框

一。首先看看EditView,这个加一个背景颜色就可以营造出,编辑框有边框的假象。

<LinearLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context="com.example.a87188.roundtextview.MainActivity">

    <LinearLayout
       android:layout_gravity="center"
        android:gravity="center"
        android:background="#66ccff"
        android:layout_width="250dp"
        android:layout_height="50dp">
    <EditText
        android:layout_width="230dp"
        android:layout_height="30dp"
        android:background="#ffffff"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintLeft_toLeftOf="parent"
        app:layout_constraintRight_toRightOf="parent"
        app:layout_constraintTop_toTopOf="parent" />
    </LinearLayout>

</LinearLayout>
二。圆角边框,渐变背景的TextView
	就是给TextView添加一个背景,和上例一样。在drawable资源文件中写背景xml
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
    <!--指定圆角矩形的4个圆角半径-->
    <corners android:topLeftRadius="20px"
        android:bottomRightRadius="20px"
        android:topRightRadius="5px"
        android:bottomLeftRadius="5px"/>
    <stroke android:width="4px" android:color="#f0f"/>
</shape>
	需要指出的是,表面上这里只是介绍TextView,但由于TextView是EditText,Button等类的父类,因此此处介绍
的对TextView控制的属性,同样适用于EditText与Button

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值