相关疑难解决方法(0)

Android定制按钮; 改变文字颜色

我做了一个按钮,改变了不同状态下的背景,这样:

 <selector xmlns:android="http://schemas.android.com/apk/res/android">
 <item android:state_pressed="true" android:drawable="@drawable/btn_location_pressed" /> <!-- pressed -->
 <item android:state_focused="true" android:drawable="@drawable/btn_location_pressed"/> <!-- focused -->
 <item android:drawable="@drawable/btn_location"/> <!-- default -->
Run Code Online (Sandbox Code Playgroud)

这里的问题是我也试图改变textColor,就像我对drawable一样,但我无法做到.我已经尝试过android:textColor和android:color但是第一个不起作用,而秒数改变了我的背景.

下一个代码是我布局的一部分.关于文本颜色,它仅适用于正常状态文本颜色,因此在按下时不会将其更改为白色

<Button android:id="@+id/location_name"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:paddingTop="5dp"
        android:background="@drawable/location"          
        android:textSize="15sp"
        android:textColor="@color/location_color"
        android:textColorHighlight="#FFFFFF"
   />
Run Code Online (Sandbox Code Playgroud)

有人有线索吗?

android android-button android-selector

245
推荐指数
3
解决办法
19万
查看次数

如何让Android文本视图看起来像被禁用?

我希望能够为任何文本视图提供与禁用它相同的方面.目前我正在使用一种继承TextAppearance并添加灰色文本颜色的样式,但我更喜欢使用内置的东西,它可以完美地与任何主题一起使用.

android styles

11
推荐指数
2
解决办法
2万
查看次数

Android - Linkify,autoLink在触摸时删除文本颜色更改

假设我在TextView中有以下文字:

Hey there, visit www.example.com

如果我设置TextView的属性autoLink ="all",将正确检测www.example.com.但是,如果我现在触摸TextView,TextView的文本不是链接('嘿那里,访问'部分)将变灰.有没有办法防止这种行为?

谢谢!

android

8
推荐指数
2
解决办法
8106
查看次数

Android Linkify链接textColor被忽略,css样式覆盖可能吗?

Linkify在我的应用程序中使用,访问过的链接文本显示为深紫色.我的整体布局背景颜色为深蓝色,因此无法阅读.文本设置为白色,但访问过的链接显示为深紫色.我该如何覆盖它?

<TextView android:text="Website:" 
          android:layout_width="match_parent" 
          android:layout_height="wrap_content"
          android:textSize="14dip"
          android:paddingBottom="2dip"
          android:background="#ffffff"
          android:textColor="#577dbe" />              
<TextView android:text="http://www.mysite.com/"
          android:layout_width="match_parent" 
          android:layout_height="wrap_content"
          android:textSize="12dip"
          android:paddingBottom="6dip"
          android:textColor="#ffffff"
          android:id="@+id/contactWeb1" />  
Run Code Online (Sandbox Code Playgroud)

android overriding textcolor textview linkify

8
推荐指数
1
解决办法
7094
查看次数

setEnabled在android中不起作用

我有这个代码:

public TextView main_text;//begining of the class

main_text = (TextView) findViewById(R.id.TextMain); //inside OnCreate

main_text.setEnabled(false); //inside button handler
Run Code Online (Sandbox Code Playgroud)

而现在是Xml的一部分

    <TextView
        android:id="@+id/TextMain"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:gravity="left"
        android:textColor="#FFFFFF"
        android:text="@string/home_load" >

    </TextView>
Run Code Online (Sandbox Code Playgroud)

为什么SetEnable不起作用?它应该是显而易见的.

java android

1
推荐指数
1
解决办法
4072
查看次数