我做了一个按钮,改变了不同状态下的背景,这样:
<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)
有人有线索吗?
我希望能够为任何文本视图提供与禁用它相同的方面.目前我正在使用一种继承TextAppearance并添加灰色文本颜色的样式,但我更喜欢使用内置的东西,它可以完美地与任何主题一起使用.
假设我在TextView中有以下文字:
Hey there, visit www.example.com
如果我设置TextView的属性autoLink ="all",将正确检测www.example.com.但是,如果我现在触摸TextView,TextView的文本不是链接('嘿那里,访问'部分)将变灰.有没有办法防止这种行为?
谢谢!
我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) 我有这个代码:
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不起作用?它应该是显而易见的.