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 */
}

```
It really depends on you. There is no "right" way to do it. It depends on how you wish to organize your stylesheets. If you have many media query rules for different viewports, then it might make more sense to do it the way you've been doing, because you're right -- it is more efficient to have sections for different media queries. The examples that you've looked at may be doing it differently to make it more easily understood to other people reading it. I think the only important thing is to try to choose a way and stick to it as much as you reasonably can. (At the same time, rules are meant to be broken occasionally.) In the long run, this will help your code be more predictable, and it'll be easier for you to understand and maintain it.