I have a relative layout in which i add a second relative layout which contains 4 buttons. when i do: relativeLayout1.addView(relativeLayout2,params)
i want that the added relative layout with the 4 buttons slides in from right to left.
Is that somehow possible?
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
%p signifies percentage of its parent. 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.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.