Textview改变位置

hshm20517 2010-09-21 05:51:13
想改变一下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();
}

...全文
1471 12 打赏 收藏 转发到动态 举报
写回复
用AI写文章
12 条回复
切换为时间正序
请发表友善的回复…
发表回复
lenomonxiao 2012-04-20
  • 打赏
  • 举报
回复
项目中使用到的,无下划线效果。Android使用TextView实现无下划线超链接
SONAIS01 2011-09-16
  • 打赏
  • 举报
回复
在哪里找的,我找不到那个 API demo
zhaodongtai192 2011-04-14
  • 打赏
  • 举报
回复

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"
/>


刚试过了,可以的,呵呵


牛叔 2010-10-12
  • 打赏
  • 举报
回复
[Quote=引用 5 楼 hshm20517 的回复:]

引用 3 楼 guoyoulei520 的回复:

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


兄弟,能明示下具体是哪个例子不?去找了下,没找到
[/Quote]

貌似在app—>animation里面。。。
大掌教 2010-09-24
  • 打赏
  • 举报
回复
API demo中有你这个效果 楼主研究下
我记得是可以让一个EditText在输入完成的时候左右抖动
luojc714 2010-09-24
  • 打赏
  • 举报
回复
楼主的问题我之前也遇到过,貌似layout在每一次刷新的时候都会计算子View的位置,而且位置是根据该layout中的相关值设定的,所以你更改子View的位置不起作用,只有更改layout中与子View位置相关的值才会起作用。比如layout.setPadding函数之类的。
hshm20517 2010-09-24
  • 打赏
  • 举报
回复
[Quote=引用 3 楼 guoyoulei520 的回复:]

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

兄弟,能明示下具体是哪个例子不?去找了下,没找到
starssn 2010-09-24
  • 打赏
  • 举报
回复
在android里面, 实现控件的移动等操作是很麻烦的, 需要重写你的layout 和控件的矩阵转换算法, 不过, 你可以利用animation来试试看, 也许, 会意想不到哦。
凉凉二点凉 2010-09-22
  • 打赏
  • 举报
回复
个人感觉可以用viewfilpper
凉凉二点凉 2010-09-22
  • 打赏
  • 举报
回复
API demo中有文字抖动的例子,可以参考下
Nico 2010-09-21
  • 打赏
  • 举报
回复
应该使用handler吧。
动态的发送消息提示页面更新这样的
zw87804600 2010-09-21
  • 打赏
  • 举报
回复
顶 学习中

80,360

社区成员

发帖
与我相关
我的任务
社区描述
移动平台 Android
androidandroid-studioandroidx 技术论坛(原bbs)
社区管理员
  • Android
  • yechaoa
  • 失落夏天
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧