安卓:在标签布局

问题描述:

Gardient动画这是启动屏幕我的应用程序启动时:安卓:在标签布局

enter image description here

我想增加光晕当标签被激活,而当离开标签减少光晕。

这是我选择的文件:

<?xml version="1.0" encoding="utf-8"?> 
<selector xmlns:android="http://schemas.android.com/apk/res/android"> 
<!-- Non focused states --> 
<item android:state_focused="false" 
     android:state_selected="false" 
     android:state_pressed="false" 
     android:drawable="@drawable/reverse_animation" /> 
<item android:state_focused="false" 
     android:state_selected="true" 
     android:state_pressed="false" 
     android:drawable="@drawable/animation" /> 

<!-- Focused states --> 
<item android:state_focused="true" 
     android:state_selected="false" 
     android:state_pressed="false" 
     android:drawable="@drawable/animation" /> 
<item android:state_focused="true" 
     android:state_selected="true" 
     android:state_pressed="false" 
     android:drawable="@drawable/animation" /> 

<!-- Pressed --> 
<item android:state_pressed="true" 
     android:drawable="@drawable/pressed" /> 

这是我的动画文件:

<?xml version="1.0" encoding="utf-8"?> 

<animation-list xmlns:android="http://schemas.android.com/apk/res/android" 
android:oneshot="true" android:visible="true" > 
<item 
    android:drawable="@drawable/phase1" 
    android:duration="20" /> 
<item 
    android:drawable="@drawable/phase2" 
    android:duration="20" />  
<item 
    android:drawable="@drawable/phase3" 
    android:duration="20" />  
<item 
    android:drawable="@drawable/phase4" 
    android:duration="20" />  
    <item 
    android:drawable="@drawable/phase5" 
    android:duration="20" />  
    <item 
    android:drawable="@drawable/phase6" 
    android:duration="20" />  
    <item 
    android:drawable="@drawable/phase7" 
    android:duration="20" />  
    <item 
    android:drawable="@drawable/phase8" 
    android:duration="20" />  
    <item 
    android:drawable="@drawable/phase9" 
    android:duration="20" />  
    <item 
    android:drawable="@drawable/phase10" 
    android:duration="20" />  
    <item 
    android:drawable="@drawable/phase11" 
    android:duration="20" /> 
    <item 
    android:drawable="@drawable/phase12" 
    android:duration="20" /> 

问题是,当应用程序启动激活标签没有光芒,但另外两个标签有光芒。

我已经在每个阶段文件中使用渐变,并增加了每个阶段的半径。 在reverse_animation文件我phase12开始阶段1

这是阶段1:

<?xml version="1.0" encoding="utf-8"?> 
<shape xmlns:android="http://schemas.android.com/apk/res/android"  
android:shape="rectangle" > 

<gradient 
    android:type="radial" 
    android:gradientRadius="1" 
    android:startColor="#DD02e4ff" 
    android:centerY="-0.16" /> 

</shape> 

请我需要对选项卡的默认设置帮助。音频选项卡应该发光,而不是其他选项卡。我在选择器文件中尝试了很多可能的组合,但无法实现这一点。谢谢!

  1. 存在animation-list没有看到android:visible="true"here
  2. android:gradientRadius="1"是非常小的。这是一个点,你移动到你的形状之上(android:centerY="-0.16")。尝试<solid android:color="#FF00FF00" />以测试是梯度故障还是给半径提供更大的值。
  3. 解决方法:使用AlphaAnimation创建一个tween-animation,并淡入渐变绘制。