为了账号安全,请及时绑定邮箱和手机立即绑定

如何在屏幕右上方对图像进行动画处理

如何在屏幕右上方对图像进行动画处理

慕码人2483693 2021-04-27 21:01:48
我是android开发的新手。我想在更改图像大小的同时将我的图像从中心移到屏幕的右上角(Smaller)。我尝试了以下操作-对translationX和translationY进行硬编码,输入-150dp这样的特定值,在我的仿真器屏幕上看起来不错,但是在各种设备上的图像位置都不同。.getX。getY方法,我试图在图像中放置一个不可见的图像(alpha 0),并在图像中放置getx和y并设置translationx,y,但它不起作用,该图像从我的屏幕上滑落。我想如果我能得到像textview这样的对象的位置并将图像位置设置为objectposition + somevalue会起作用,但是我不知道该怎么做。有人可以帮我吗?这是我正在尝试做的图像。提前致谢。
查看完整描述

2 回答

?
慕的地8271018

TA贡献1796条经验 获得超4个赞

试试这个,希望这段代码对您有所帮助

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:orientation="horizontal">
    <TextView
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:text="Your Text"
        android:layout_gravity="center"/>
    <ImageView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:src="@android:drawable/star_big_off" /></LinearLayout>


查看完整回答
反对 回复 2021-05-12
  • 2 回答
  • 0 关注
  • 106 浏览

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信