除了按钮文本的Andr​​oid按钮动画 [英] Android button animation except button text

查看:169
本文介绍了除了按钮文本的Andr​​oid按钮动画的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在我的Andr​​oid应用程序的动画按钮。当动画开始,也该按钮文字动画效果。但我不需要这样的动画。是否有只保留按钮背景动画的任何解决方案。

I have an animated button in my android application. When the animation starts, also the button text is animated. But I do not need that animation. Is there any solution that keeps only the button background animation.

对不起,我英文不好。

下面是动画文件夹我的动画XML:

Here is my animation XML in anim folder:

<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android"
android:interpolator="@android:anim/linear_interpolator">
<rotate
   android:fromDegrees="0"
   android:toDegrees="360"
   android:pivotX="50%"
   android:pivotY="50%"
   android:duration="500"
   android:startOffset="0"
   android:repeatCount="infinite"
   android:repeatMode="restart" />
</set>

下面是我在布局文件夹按钮:

Here is my button in layout folder:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >

<RelativeLayout
    android:id="@+id/relativeLayout1"
    android:layout_width="match_parent"
    android:layout_height="wrap_content" >

    <ImageView
        android:id="@+id/imageView1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentLeft="true"
        android:layout_alignParentTop="true"
        android:src="@drawable/firstscreenimage" />

</RelativeLayout>

<Button
    android:id="@+id/button1"
    android:layout_width="150dp"
    android:layout_height="150dp"
    android:layout_alignParentBottom="true"
    android:layout_centerHorizontal="true"
    android:layout_marginBottom="35dp"
    android:background="@drawable/animation0"
    android:text="Start" />

<TextView
    android:id="@+id/textView1"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentRight="true"
    android:layout_below="@+id/relativeLayout1"
    android:layout_marginRight="28dp"
    android:layout_marginTop="26dp"
    android:text="0.0km"
    android:textSize="30dp" />

<EditText
    android:id="@+id/editText1"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:layout_alignParentBottom="true"
    android:layout_centerHorizontal="true" >

    <requestFocus />
</EditText>

</RelativeLayout>

和这里是我的活动,我开始动画:

And here is my activity that I started the animation:

 public class Gps extends Activity {

TextView display;
Button start;
boolean doubleclick = false;
AnimationDrawable AppNameAnimation;

double currentLon = 0;
double currentLat = 0;
double lastLon = 0;
double lastLat = 0;
double distance;

LocationManager lm;

public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_test);

    display = (TextView) findViewById(R.id.textView1);
    start = (Button) findViewById(R.id.button1);
    final Animation animRotate = AnimationUtils.loadAnimation(this,
            R.anim.anim_rotate);

    start.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            // TODO Auto-generated method stub
            if (!doubleclick) {
                v.startAnimation(animRotate);
                start.setText("stop");
                lm = (LocationManager) getSystemService(LOCATION_SERVICE);
                lm.requestLocationUpdates(lm.GPS_PROVIDER, 0, 0, Loclist);
                Location loc = lm.getLastKnownLocation(lm.GPS_PROVIDER);

                if (loc == null) {
                    display.setText("No GPS location found");
                } else {
                    // set Current latitude and longitude
                    currentLon = loc.getLongitude();
                    currentLat = loc.getLatitude();

                }
                // Set the last latitude and longitude
                lastLat = currentLat;
                lastLon = currentLon;
                doubleclick = true;
            } else {
                lm.removeUpdates(Loclist);
                start.setText("start");
                v.clearAnimation();
                doubleclick = false;
                Intent in = new Intent(Gps.this, NextActivity.class);
                startActivity(in);
            }

        }
    });
}

请帮我。

推荐答案

最简单的解决方案这是继
删除按钮文本
添加文本查看
把它放在一个按钮
按钮的动画效果韩元吨TextView的都将被另案处理,你的文字动画问题将得到解决。

The Simplest Solution for this is following Remove Button text Add Text View place it over button button animation won`t effect TextView both will be handled separately and your text animation problem will be solved

这篇关于除了按钮文本的Andr​​oid按钮动画的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆