Android 更改按钮的X和Y位置/动态更改按钮的边距

Android 更改按钮的X和Y位置/动态更改按钮的边距,android,margin,Android,Margin,我想更改我的按钮在d应用程序中的边距。。。 假设我在线性布局中有5个这样的按钮,一个在d下面另一个 当我关注一个按钮时,它的宽度应该增加(我知道如何处理),同时,宽度应该向左右线性增加 i、 e.如果按钮的当前宽度为250,x坐标为50(这意味着按钮的左侧为50,右侧为300),当我聚焦于按钮时,我应该得到x坐标为75(左侧为25,右侧为325)。如何更改按钮的边距/x坐标?请查看位于和的动画和缩放动画类 一种方法是在res/anim目录中定义两个XML文件,一个使按钮变大,另一个使按钮变小。因

我想更改我的按钮在d应用程序中的边距。。。 假设我在线性布局中有5个这样的按钮,一个在d下面另一个

当我关注一个按钮时,它的宽度应该增加(我知道如何处理),同时,宽度应该向左右线性增加


i、 e.如果按钮的当前宽度为250,x坐标为50(这意味着按钮的左侧为50,右侧为300),当我聚焦于按钮时,我应该得到x坐标为75(左侧为25,右侧为325)。如何更改按钮的边距/x坐标?

请查看位于和的
动画
缩放动画

一种方法是在
res/anim
目录中定义两个XML文件,一个使按钮变大,另一个使按钮变小。因此对于
makebiger.xml

<scale xmlns:android="http://schemas.android.com/apk/res/android" 
android:interpolator="@android:anim/accelerate_decelerate_interpolator" 
android:fromXScale="1" 
android:toXScale="1.1" 
android:pivotX="50%" 
android:pivotY="50%" 
android:duration="200" 
android:fillAfter="true" />
当然,当您触摸按钮时,应该设置makeBiger和makeSmaller动画


我希望这有帮助

在和查看
动画
缩放动画
课程

一种方法是在
res/anim
目录中定义两个XML文件,一个使按钮变大,另一个使按钮变小。因此对于
makebiger.xml

<scale xmlns:android="http://schemas.android.com/apk/res/android" 
android:interpolator="@android:anim/accelerate_decelerate_interpolator" 
android:fromXScale="1" 
android:toXScale="1.1" 
android:pivotX="50%" 
android:pivotY="50%" 
android:duration="200" 
android:fillAfter="true" />
当然,当您触摸按钮时,应该设置makeBiger和makeSmaller动画


我希望这有帮助

当然,因为……它确实有帮助……thanx很多……:-)当然,因为……它确实有帮助……thanx很多……:-)