zoukankan      html  css  js  c++  java
  • android 界面控件 textview 全解

    textview基本使用:

    <TextView
    10.        android:id="@+id/txtOne"
    11.        android:layout_width="200dp"
    12.        android:layout_height="200dp"
    13.        android:gravity="center"//设置该控件中内容的对齐方式,注意区别layout_gravity
    14.        android:text="TextView(显示框)"
    15.        android:textColor="#EA5246"
    16.        android:textStyle="bold|italic"//设置字体风格
    17.        android:background="#000000"
    18.        android:textSize="18sp" />
    19. 

    进阶1:

    带阴影的textview:

    <TextView
    2.        android:layout_width="wrap_content"
    3.        android:layout_height="wrap_content"
    4.        android:layout_centerInParent="true"
    5.        android:shadowColor="#F9F900"//设置阴影颜色
    6.        android:shadowDx="10.0"//水平偏移的位移
    7.        android:shadowDy="10.0"//竖直
    8.        android:shadowRadius="3.0"//甚至阴影的模糊程度
    9.        android:text="带阴影的TextView"
    10.        android:textColor="#4A4AFF"
    11.        android:textSize="30sp" />

    进阶2:

    带边框的textview:

    先画一个drawable然后背景设为这个就行了
    矩形边框
    1.<?xml version="1.0" encoding="utf-8"?>
    2.<shape xmlns:android="http://schemas.android.com/apk/res/android" >
    3. 
    4.    <!-- 设置一个黑色边框 -->
    5.    <stroke android:width="2px" android:color="#000000"/>
    6.    <!-- 渐变 -->
    7.    <gradient
    8.        android:angle="270"
    9.        android:endColor="#C0C0C0"
    10.        android:startColor="#FCD209" />
    11.    <!-- 设置一下边距,让空间大一点 -->
    12.    <padding
    13.        android:left="5dp"
    14.        android:top="5dp"
    15.        android:right="5dp"
    16.        android:bottom="5dp"/>
    17. 
    18.</shape>
    圆形边框
    <?xml version="1.0" encoding="utf-8"?>
    2.<shape xmlns:android="http://schemas.android.com/apk/res/android">
    3. 
    4.    <!-- 设置透明背景色 -->
    5.    <solid android:color="#87CEEB" />
    6. 
    7.    <!-- 设置一个黑色边框 -->
    8.    <stroke
    9.        android:width="2px"
    10.        android:color="#000000" />
    11.    <!-- 设置四个圆角的半径 -->
    12.    <corners
    13.        android:bottomLeftRadius="10px"
    14.        android:bottomRightRadius="10px"
    15.        android:topLeftRadius="10px"
    16.        android:topRightRadius="10px" />
    17.    <!-- 设置一下边距,让空间大一点 -->
    18.    <padding
    19.        android:bottom="5dp"
    20.        android:left="5dp"
    21.        android:right="5dp"
    22.        android:top="5dp" />
    23.        
    24.</shape>

    进阶3:

    带图片的textview

    7.     <TextView  
    8.          android:layout_width="wrap_content"  
    9.          android:layout_height="wrap_content"  
    10.        android:layout_centerInParent="true"  
    11.        android:drawableTop="@drawable/show1"  //设置文字上方的图片
    12.        android:drawableLeft="@drawable/show1"  
    13.        android:drawableRight="@drawable/show1"  
    14.        android:drawableBottom="@drawable/show1"  
    15.        android:drawablePadding="10dp"  //设置文字与图片的距离
    16.        android:text="微信" />  
    17.  

    4:

    使用autoLink属性识别链接类型

    <TextView
        ....
        andorid:text="www.baidu.com"
        android:autolink="email/phone/map/...."
    />
  • 相关阅读:
    asp.net 验证输入有效性
    优化SQL SERVER访问性能
    with nocheck ; nocheck
    VB SStab设置当前页
    相互关联的子查询
    mybatis 批量查询参数语句
    转载 mysql函数大全
    Tchar.h 中的一般文本映射
    字节序的概念、判断、及转换
    Windows风格与C/C++风格:UNICODE VS _UNICODE 与 TEXT() VS _T()
  • 原文地址:https://www.cnblogs.com/zzy-frisrtblog/p/5363812.html
Copyright © 2011-2022 走看看