[英]How to add relative layout to relative layout with slide in effect?
我有一個相對布局,在其中我添加了一個包含4個按鈕的第二個相對布局。 當我這樣做時: relativeLayout1.addView(relativeLayout2,params)
我希望添加的具有4個按鈕的相對布局從右向左滑動。
有可能嗎?
xml:
<translate xmlns:android="http://schemas.android.com/apk/res/android" android:duration="500" android:fromXDelta="100%" android:toXDelta="0%" > </translate>
代碼:```
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);
}
而不是100%
和0%
使用100%p
和0%p
%p表示其父級的百分比。 我認為這就是您想要做的。
現在正在工作,
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));
無需在動畫之前將其設置為不可見。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.