【发布时间】:2017-10-28 14:38:28
【问题描述】:
我正在开发一个 android 应用程序,我想在单个圆形区域中显示字母,我还需要圆形区域为白色,并且字母表具有我的应用程序的 primaryColor,
这是我的textView:
<TextView
android:id="@+id/first"
android:layout_width="0dip"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="A"
android:background="@drawable/circle" />
这是drawable 文件夹中circle.xml 的代码:
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="oval" >
<stroke android:width="1dp" android:color="@color/colorPrimaryDark" />
<gradient android:startColor="@color/white" android :endColor="@color/white"
android:angle="270"
/>
</shape>
这是filled_circle的代码:
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="oval" >
<stroke android:width="1dp" android:color="@color/colorPrimaryLight" />
<gradient android:startColor="@color/colorPrimaryLight"
android:endColor="@color/colorPrimaryLight"
android:angle="270"
/>
</shape>
和java文件中的代码:
@Override
public void onClick(View v) {
}
问题
当单击字母表的每个文本区域时,白色应该淡出,primaryColor 应该淡入,并带有动画。
有人可以帮忙吗,在 android 4 及更高版本的 animation 库的帮助下完成这项工作?
我目前正在尝试用另一个资源替换 textview 的背景并对其应用动画,但我完全愿意接受任何新的建议和执行此操作的新方式,
我还在上面提供了我当前的代码,但如果我必须进行根本性更改或修改以使其与 animation 库一起使用,请告诉我?
【问题讨论】:
标签: android animation android-animation textview