想改变一下Textview的位置,比如左移多少,右移多少,形成抖动的效果。
用下面代码试着改变下控件的位置,发现不行。高手们,如何处理呀?//改变球的位置
private void changeLocation(TextView tv){
int top = tv.getTop();
int left = tv.getLeft();
tv.layout(left + 20, top, left + 20 + tv.getWidth(), top + tv.getHeight());
tv.invalidate();
}

解决方案 »

  1.   

    应该使用handler吧。
    动态的发送消息提示页面更新这样的
      

  2.   

    API demo中有文字抖动的例子,可以参考下
      

  3.   

    楼主的问题我之前也遇到过,貌似layout在每一次刷新的时候都会计算子View的位置,而且位置是根据该layout中的相关值设定的,所以你更改子View的位置不起作用,只有更改layout中与子View位置相关的值才会起作用。比如layout.setPadding函数之类的。
      

  4.   

    API demo中有你这个效果 楼主研究下
    我记得是可以让一个EditText在输入完成的时候左右抖动
      

  5.   

    在android里面, 实现控件的移动等操作是很麻烦的, 需要重写你的layout 和控件的矩阵转换算法, 不过, 你可以利用animation来试试看, 也许, 会意想不到哦。
      

  6.   


    貌似在app—>animation里面
      

  7.   


            Animation shake = AnimationUtils.loadAnimation(this, R.anim.shake);
            findViewById(R.id.pw).startAnimation(shake);<?xml version="1.0" encoding="utf-8"?>
    <!-- Copyright (C) 2007 The Android Open Source Project     Licensed under the Apache License, Version 2.0 (the "License");
         you may not use this file except in compliance with the License.
         You may obtain a copy of the License at
      
              http://www.apache.org/licenses/LICENSE-2.0
      
         Unless required by applicable law or agreed to in writing, software
         distributed under the License is distributed on an "AS IS" BASIS,
         WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
         See the License for the specific language governing permissions and
         limitations under the License.
    --><cycleInterpolator xmlns:android="http://schemas.android.com/apk/res/android" android:cycles="7" />
    [code=XML]
    <?xml version="1.0" encoding="utf-8"?>
    <!-- Copyright (C) 2007 The Android Open Source Project     Licensed under the Apache License, Version 2.0 (the "License");
         you may not use this file except in compliance with the License.
         You may obtain a copy of the License at
      
              http://www.apache.org/licenses/LICENSE-2.0
      
         Unless required by applicable law or agreed to in writing, software
         distributed under the License is distributed on an "AS IS" BASIS,
         WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
         See the License for the specific language governing permissions and
         limitations under the License.
    --><translate xmlns:android="http://schemas.android.com/apk/res/android" 
    android:fromXDelta="0" 
    android:toXDelta="10" 
    android:duration="1000" 
    android:interpolator="@anim/cycle_7" 
    />
    刚试过了,可以的,呵呵
      

  8.   

    在哪里找的,我找不到那个 API demo
      

  9.   

    项目中使用到的,无下划线效果。Android使用TextView实现无下划线超链接