[英]How to add relative layout to relative layout with slide in effect?
I have a relative layout in which i add a second relative layout which contains 4 buttons. 我有一个相对布局,在其中我添加了一个包含4个按钮的第二个相对布局。 when i do:
relativeLayout1.addView(relativeLayout2,params)
i want that the added relative layout with the 4 buttons slides in from right to left. 当我这样做时:
relativeLayout1.addView(relativeLayout2,params)
我希望添加的具有4个按钮的相对布局从右向左滑动。
Is that somehow possible? 有可能吗?
xml: xml:
<translate xmlns:android="http://schemas.android.com/apk/res/android" android:duration="500" android:fromXDelta="100%" android:toXDelta="0%" > </translate>
code: ``` 代码:```
public Panel(Context context) {
super(context);
this.setBackgroundColor(Color.BLACK);
this.setId(R.id.panel);
right_menubar = new RelativeLayout(context);
right_menubar.setId(R.id.panel_indicators);
plp_right_menu_bar = new RelativeLayout.LayoutParams(100, 100);
this.addView(right_menubar, plp_right_menu_bar);
Animation fadeIn = AnimationUtils.loadAnimation(context, R.animator.anim);
right_menubar.startAnimation(fadeIn);
}
instead of 100%
and 0%
use 100%p
and 0%p
而不是
100%
和0%
使用100%p
和0%p
%p signifies percentage of its parent. %p表示其父级的百分比。 i think that is what you are trying to do.
我认为这就是您想要做的。
It is working now, 现在正在工作,
right_menubar.setId(R.id.panel_indicators);
plp_right_menu_bar = new RelativeLayout.LayoutParams(100, 100);
plp_right_menu_bar.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
this.addView(right_menubar, plp_right_menu_bar);
right_menubar.startAnimation(AnimationUtils.loadAnimation(this.getContext(), R.animator.anim));
No need to set it to invisible before the animation. 无需在动画之前将其设置为不可见。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.