03安卓TextView

来源:互联网 发布:c 语言编辑器 编辑:程序博客网 时间:2024/06/17 17:37


一  TextView    父类 : View
    >概念:文本控件 :文本内容的显示   默认配置不可编辑  子类EditText可以编辑
    

*********************************

注意:安卓中如果在TextView中英文混用将有空可能自动折断到下行 ,如果是中文符号和英文混用将中文符号转换为半角。在安卓5.0后解决了这个BUG 或者删除 详情解决办法:http://niufc.iteye.com/blog/1729792


*********************************

    >属性:

    android:text="你好,世界!"        文本内容
        android:textSize="20sp"   文本字体的大小
        android:textColor="#f00"  文本颜色
        android:textStyle="bold|italic"   文本字体样式   
        bold:加粗

        italic:斜体

        android:maxLength="1" 最大显示字符数

        android:maxLines="2":文本最多展示的行数

       android:singleLine="true"    文本过多单行展示文本内容
        android:ellipsize="none"   省略号的位置
        none:  没有
        start:开始位置
        middle:中间位置
        end:结尾位置
        
        marquee:跑马灯

        跑马灯必要条件:
        android:singleLine="true"    单行展示
        android:ellipsize="marquee"  设置成跑马灯样式
        android:focusableInTouchMode="true"  设置获取焦点模式
        android:focusable="true"   设置获取焦点
        android:marqueeRepeatLimit="marquee_forever"   跑马灯无限循环

    android:autoLink="phone"自动链接  (根据内容不同  打开相应的程序)
          phone  电话
          web    网址
          map    地图
          email  邮箱
          all    以上所有


       设置阴影效果
        android:shadowColor="#0f0"   阴影的颜色
        android:shadowDx="10.0"     阴影水平偏移量
        android:shadowDy="8.0"      阴影垂直偏移量

        android:shadowRadius="2"    阴影模糊程度   (值越大 越模糊)

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"    xmlns:tools="http://schemas.android.com/tools"    android:layout_width="match_parent"    android:layout_height="match_parent"    android:orientation="vertical"    android:paddingBottom="@dimen/activity_vertical_margin"    android:paddingLeft="@dimen/activity_horizontal_margin"    android:paddingRight="@dimen/activity_horizontal_margin"    android:paddingTop="@dimen/activity_vertical_margin"    tools:context="com.fmy.img.MainActivity" >    <!--    android:maxLength="1"设置最大字符数    android:textColor="#ff0000"设置颜色          -->    <TextView        android:layout_width="wrap_content"        android:layout_height="wrap_content"        android:maxLength="1"        android:text="Hello wrold"        android:textColor="#ff0000" /><!--   android:textColor="#ff0000"设置颜色   android:textStyle="italic|bold"设置斜体和加粗  -->    <TextView        android:layout_width="wrap_content"        android:layout_height="wrap_content"        android:text="Hello wrold"        android:textColor="#ff0000"        android:textStyle="italic|bold" /><!--   android:singleLine="true"设置单行  -->    <TextView        android:layout_width="wrap_content"        android:layout_height="wrap_content"        android:singleLine="true"        android:text="Hello wrold Hello wrold Hello wrold Hello wrold Hello wrold Hello wrold Hello wrold" /><!--   android:maxLines="2"设置最大行数 android:ellipsize="middle"设置省略中间文字 android:ellipsize="start"设置省略开始文字 android:ellipsize="end"设置省略文字后端-->    <TextView        android:layout_width="wrap_content"        android:layout_height="wrap_content"        android:ellipsize="start"        android:maxLines="2"        android:text="Hello wrold Hello wrold Hello wrold Hello wrold Hello wrold Hello wrold Hello 我是最后" /><!--ellipsize="marquee"设置跑马灯设置跑马灯的前提:focusableInTouchMode 设置焦点模式marqueeRepeatLimit 设置跑马灯循环次数singleLine="true"设置单行focusable 获得焦点  -->    <TextView        android:layout_width="wrap_content"        android:layout_height="wrap_content"        android:ellipsize="marquee"        android:focusable="true"        android:focusableInTouchMode="true"        android:marqueeRepeatLimit="marquee_forever"        android:singleLine="true"        android:text="Hello wrold Hello wrold Hello wrold Hello wrold Hello wrold Hello wrold Hello 我是最后" /><!--    android:autoLink="map"打开地图   android:autoLink="phone"打开text的电话   android:autoLink="web"打开text的网页   android:autoLink="email"设置text的邮箱链接到邮箱       android:text="635555698@qq.com" -->    <TextView        android:layout_width="wrap_content"        android:layout_height="wrap_content"        android:autoLink="map"        android:text="635555698@qq.com" /><!--     android:shadowDx="10" 设置阴影x离左上角的位置        android:shadowDy="10" 设置阴影y离左上角的位置android:shadowRadius="2" 設置影印模糊度 -->    <TextView        android:shadowDx="10"        android:shadowDy="10"        android:shadowRadius="2"        android:shadowColor="#f00"        android:layout_width="wrap_content"        android:layout_height="wrap_content"        android:text="影音效果" /></LinearLayout>



0 0
原创粉丝点击