Question: 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.

[![example](https://i.stack.imgur.com/qNHDk.png)](https://i.stack.imgur.com/qNHDk.png)

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);

}

```

Answer: 
Clearly one would prefer to group the media query versions of the CSS rules together with the non-media query versions, so they can be managed together. For example, if I write separate CSS for each component, I would usually want both media query versions and non-media query versions of the rules for that component to be in the file for that component. When I add and modify rules, I would prefer to do that in one place, rather than two or more.

If it bothers you that you have to write the media query again and again, which is a valid concern from the standpoint of maintaining your code when changing breakpoints, consider using a preprocessor such as postCSS which allows you to define aliases for media queries. For instance, [this plugin](https://github.com/postcss/postcss-custom-media) would allow you to write

```
@custom-media --small-viewport (max-width: 30em);

@media (--small-viewport) {
  /* styles for small viewport */
}

```
The Second option is the better way to do it.As if there occurs any change in CSS after sometime then you need to find the class for normal CSS as well as Media Queries.

In this case you just need to search for it once only.