我有一个textview,我会把它的背景颜色设置为全光绿色,如
here.所述
但是,我不知道如何通过XML来做到这一点.可能吗?我目前有:
<TextView android:text="2" android:textSize="200sp" android:layout_width="fill_parent" android:layout_height="fill_parent" android:id="@+id/textView2" android:background="#00FF00" android:gravity="center" android:textColor="#EEEEEE" android:layout_alignParentRight="true" />
但是,我无法改变android:背景以某种方式引用全息绿光.
有没有人有什么建议?我试过“@android:color /”,但没有骰子.
解决方法
通过Java:
TextView test = (TextView) view.findViewById(R.id.textView2); test.setBackgroundResource(context.getResources().getColor(android.R.color.holo_green_light));
通过XML:
<TextView android:text="2" android:textSize="200sp" android:layout_width="fill_parent" android:layout_height="fill_parent" android:id="@+id/textView2" android:style="@style/textviewStyle" android:background="@android:color/holo_green_light" android:gravity="center" android:textColor="#EEEEEE" android:layout_alignParentRight="true" />
原文地址:https://www.jb51.cc/android/313232.html
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。