zoukankan      html  css  js  c++  java
  • listview改变选中行字体颜色

    目标:选中item,其字体设置为#3197FF,未选中的,其字体为#FFFFFF

    与listvew设置选中行item背景图片一样,使用selector,不过这里的颜色设置,应该是在listview中的textview中设置。

    <?xml version="1.0" encoding="utf-8"?> 
    <TableLayout
        xmlns:android="http://schemas.android.com/apk/res/android"   
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        >
             <TableRow >
             <TextView
                android:id="@+id/name_tv" 
                android:layout_height="wrap_content"
                android:layout_width="wrap_content"
                android:textSize="25px"
                android:textColor="@drawable/itemcolor"> 
             </TextView>
             </TableRow>
    </TableLayout>



    同样,定义itemcolor.xml文件,修改选中行的字体颜色:

    <?xml version="1.0" encoding="utf-8" ?>
    <selector xmlns:android="http://schemas.android.com/apk/res/android"> 
    <!-- 没有焦点时字体颜色 -->
    <item
        android:state_selected="false"
        android:color="#FFFFFF"/>
    <!--选中时的字体颜色  --> 
    <item
        android:state_selected="true"
        android:color="#3197FF"/>
    <!-- 非触摸模式下获得焦点并单击时的字体颜色 --> 
    <item
        android:state_focused="true"
        android:state_pressed="true"
        android:color="#3197FF"/>
    </selector>


    bg

  • 相关阅读:
    按钮,文本框
    d01
    第一天,对于课程和工作的了解
    javaweb概念性知识
    Jdbc概念性知识
    连接数据库,和数据增删改
    oracle基础概念性知识
    面向对象java知识汇总题
    javaweb
    date日期
  • 原文地址:https://www.cnblogs.com/snake-hand/p/3144946.html
Copyright © 2011-2022 走看看