Android的TextView中禁用变色 [英] Android TextView disabling color-changing

查看:882
本文介绍了Android的TextView中禁用变色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有下面的XML(它在视图中的唯一的东西)一个TextView:

I have a TextView with the following XML (it's the only thing in the view):

<?xml version="1.0" encoding="utf-8"?>
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
  android:id="@+id/ipg_display"
  android:layout_width="fill_parent"
  android:layout_height="fill_parent"
  android:text="textview"
  android:scrollbars = "vertical"
  android:fillViewport = "true" android:clickable="false"/>

我遇到的问题是,当文本视图被用户点击(通过它或任何拖),文本稍稍改变颜色,如果视图被点击。如何禁用呢?

The problem I'm having is that when the text view is clicked by the user (to drag through it or whatever), the text changes color slightly as if the view is being "clicked". How do I disable this?

我希望设置点击,以虚假的就解决了问题,但没有运气:(

I was hoping that settings "clickable" to false would solve the issue, but no luck :(

我是什么失踪?

推荐答案

使用下面选择你作为背景按钮。并确保每个项目都有相同的颜色。

use the following selector for your button as the background. and make sure every item has the same color.

<?xml version="1.0" encoding="utf-8"?>
<selector
  xmlns:android="http://schemas.android.com/apk/res/android">
  <item 
    android:state_focused="true"
    android:drawable="@color/yourbackgroundcolor"/>
   <item 
    android:state_pressed="true"
    android:drawable="@color/yourbackgroundcolor"/>
  <item android:drawable="@color/yourbackgroundcolor"/>
</selector>

心连心。

这篇关于Android的TextView中禁用变色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆