I am facing a problem while setting the **Theme** to my Activity. Every thing works perfectly in Pre-Lollipop devices.

I want to achieve this layout design :

**image:1**

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

I have already done that by this xml : 

**design.xml**

```
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@color/spec_back"
android:orientation="vertical"
android:weightSum="1">

<ScrollView
    android:id="@+id/scrollView1"
    android:layout_width="fill_parent"
    android:layout_height="0dp"
    android:layout_weight="1"
    android:background="@color/spec_back"
    android:scrollbars="none">

    <LinearLayout
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_gravity="center_horizontal"
        android:orientation="vertical">

        <LinearLayout
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_marginLeft="5dp"
            android:layout_marginRight="5dp"
            android:layout_marginTop="10dp"
            android:orientation="horizontal"
            android:weightSum="3">

            <LinearLayout
                android:layout_width="0dp"
                android:layout_height="wrap_content"
                android:layout_weight="3"
                android:background="@color/transparent"
                android:orientation="vertical">

                <LinearLayout
                    android:layout_width="fill_parent"
                    android:layout_height="30dp"
                    android:layout_margin="1dp"
                    android:background="@color/transparent"
                    android:orientation="horizontal"
                    android:weightSum="6">

                    <Button
                        android:id="@+id/btn_cut"
                        android:layout_width="0dp"
                        android:layout_height="wrap_content"
                        android:layout_gravity="center"
                        android:layout_marginRight="1dp"
                        android:layout_weight="1"
                        android:background="@color/blue_spec"
                        android:clickable="false"

                        android:gravity="left|center"
                        android:paddingLeft="3dp"
                        android:text="@string/CUT"
                        android:textColor="@color/white"
                        android:textSize="@dimen/font_12" />

                    <Button
                        android:id="@+id/btn_cut_ex"
                        style="@android:style/ButtonBar"
                        android:layout_width="0dp"
                        android:layout_height="wrap_content"
                        android:layout_gravity="center"
                        android:layout_marginRight="1dp"
                        android:layout_weight="1"
                        android:background="@color/gray_spec"
                        android:text="@string/EX"
                        android:textColor="@color/white"
                        android:textSize="@dimen/font_12" />

                    <Button
                        android:id="@+id/btn_cut_vg"
                        style="@android:style/ButtonBar"
                        android:layout_width="0dp"
                        android:layout_height="wrap_content"
                        android:layout_gravity="center"
                        android:layout_marginRight="1dp"
                        android:layout_weight="1"
                        android:background="@color/gray_spec"
                        android:text="@string/VG"
                        android:textColor="@color/white"
                        android:textSize="@dimen/font_12" />

                    <Button
                        android:id="@+id/btn_cut_g"
                        android:layout_width="0dp"
                        android:layout_height="wrap_content"
                        android:layout_gravity="center"
                        android:layout_marginRight="1dp"
                        android:layout_weight="1"
                        android:background="@color/gray_spec"
                        android:text="@string/G"
                        android:textColor="@color/white"
                        android:textSize="@dimen/font_12" />

                    <Button
                        android:id="@+id/btn_cut_f"
                        android:layout_width="0dp"
                        android:layout_height="wrap_content"
                        android:layout_gravity="center"
                        android:layout_marginRight="1dp"
                        android:layout_weight="1"
                        android:background="@color/gray_spec"
                        android:text="@string/G"
                        android:textColor="@color/white"
                        android:textSize="@dimen/font_12" />

                    <Button
                        android:id="@+id/btn_tex"
                        android:layout_width="0dp"
                        android:layout_height="wrap_content"
                        android:layout_gravity="center"
                        android:layout_weight="1"
                        android:background="@drawable/square_trans"
                        android:text="@string/tex"
                        android:textColor="@color/blue_spec"
                        android:textSize="@dimen/font_12" />
                </LinearLayout>

                <LinearLayout
                    android:layout_width="fill_parent"
                    android:layout_height="30dp"
                    android:layout_marginBottom="1dp"
                    android:layout_marginLeft="1dp"
                    android:layout_marginRight="1dp"
                    android:orientation="horizontal"
                    android:weightSum="6">

                    <Button
                        android:id="@+id/btn_pol"
                        android:layout_width="0dp"
                        android:layout_height="wrap_content"
                        android:layout_marginRight="1dp"
                        android:layout_weight="1"
                        android:background="@color/blue_spec"
                        android:clickable="false"
                        android:gravity="left|center"
                        android:paddingLeft="3dp"
                        android:text="@string/POL"
                        android:textColor="@color/white"
                        android:textSize="@dimen/font_12" />

                    <Button
                        android:id="@+id/btn_pol_ex"
                        android:layout_width="0dp"
                        android:layout_height="wrap_content"
                        android:layout_gravity="center"
                        android:layout_marginRight="1dp"
                        android:layout_weight="1"
                        android:background="@color/gray_spec"
                        android:text="@string/EX"
                        android:textColor="@color/white"
                        android:textSize="@dimen/font_12" />

                    <Button
                        android:id="@+id/btn_pol_vg"
                        android:layout_width="0dp"
                        android:layout_height="wrap_content"
                        android:layout_gravity="center"
                        android:layout_marginRight="1dp"
                        android:layout_weight="1"
                        android:background="@color/gray_spec"
                        android:text="@string/VG"
                        android:textColor="@color/white"
                        android:textSize="@dimen/font_12" />

                    <Button
                        android:id="@+id/btn_pol_g"
                        android:layout_width="0dp"
                        android:layout_height="wrap_content"
                        android:layout_gravity="center"
                        android:layout_marginRight="1dp"
                        android:layout_weight="1"
                        android:background="@color/gray_spec"
                        android:text="@string/G"
                        android:textColor="@color/white"
                        android:textSize="@dimen/font_12" />

                    <Button
                        android:id="@+id/btn_pol_f"
                        android:layout_width="0dp"
                        android:layout_height="wrap_content"
                        android:layout_gravity="center"
                        android:layout_marginRight="1dp"
                        android:layout_weight="1"
                        android:background="@color/gray_spec"
                        android:text="@string/G"
                        android:textColor="@color/white"
                        android:textSize="@dimen/font_12" />

                    <Button
                        android:id="@+id/btn_tvg"
                        android:layout_width="0dp"
                        android:layout_height="wrap_content"
                        android:layout_gravity="center"
                        android:layout_weight="1"
                        android:background="@drawable/square_trans"
                        android:text="@string/tvg"
                        android:textColor="@color/blue_spec"
                        android:textSize="@dimen/font_12" />
                </LinearLayout>

                <LinearLayout
                    android:layout_width="fill_parent"
                    android:layout_height="30dp"
                    android:layout_marginBottom="1dp"
                    android:layout_marginLeft="1dp"
                    android:layout_marginRight="1dp"
                    android:orientation="horizontal"
                    android:weightSum="6">

                    <Button
                        android:id="@+id/btn_sym"
                        android:layout_width="0dp"
                        android:layout_height="wrap_content"
                        android:layout_marginRight="1dp"
                        android:layout_weight="1"
                        android:background="@color/blue_spec"
                        android:clickable="false"
                        android:gravity="left|center"
                        android:paddingLeft="3dp"
                        android:text="@string/SYM"
                        android:textColor="@color/white"
                        android:textSize="@dimen/font_12" />

                    <Button
                        android:id="@+id/btn_sym_ex"
                        android:layout_width="0dp"
                        android:layout_height="wrap_content"
                        android:layout_gravity="center"
                        android:layout_marginRight="1dp"
                        android:layout_weight="1"
                        android:background="@color/gray_spec"
                        android:text="@string/EX"
                        android:textColor="@color/white"
                        android:textSize="@dimen/font_12" />

                    <Button
                        android:id="@+id/btn_sym_vg"
                        android:layout_width="0dp"
                        android:layout_height="wrap_content"
                        android:layout_gravity="center"
                        android:layout_marginRight="1dp"
                        android:layout_weight="1"
                        android:background="@color/gray_spec"
                        android:text="@string/VG"
                        android:textColor="@color/white"
                        android:textSize="@dimen/font_12" />

                    <Button
                        android:id="@+id/btn_sym_g"
                        android:layout_width="0dp"
                        android:layout_height="wrap_content"
                        android:layout_gravity="center"
                        android:layout_marginRight="1dp"
                        android:layout_weight="1"
                        android:background="@color/gray_spec"
                        android:text="@string/G"
                        android:textColor="@color/white"
                        android:textSize="@dimen/font_12" />

                    <Button
                        android:id="@+id/btn_sym_f"
                        android:layout_width="0dp"
                        android:layout_height="wrap_content"
                        android:layout_gravity="center"
                        android:layout_marginRight="1dp"
                        android:layout_weight="1"
                        android:background="@color/gray_spec"
                        android:text="@string/F"
                        android:textColor="@color/white"
                        android:textSize="@dimen/font_12" />

                    <Button
                        android:id="@+id/btn_nobgm"
                        android:layout_width="0dp"
                        android:layout_height="wrap_content"
                        android:layout_gravity="center"
                        android:layout_weight="1"
                        android:background="@drawable/square_trans"
                        android:text="@string/nobgm"
                        android:textColor="@color/blue_spec"
                        android:textSize="@dimen/font_12" />
                </LinearLayout>
            </LinearLayout>
        </LinearLayout>

        <LinearLayout
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_gravity="center"
            android:layout_marginLeft="5dp"
            android:layout_marginRight="5dp"
            android:layout_marginTop="20dp"
            android:orientation="vertical">
        </LinearLayout>
    </LinearLayout>
</ScrollView>

</LinearLayout>

```

I have specified margins of `1dp` to my buttons to see them separated from each other.This layout works perfectly for Pre-Lollipop devices. But for Lollipop it gets merged despite the margins are there. I cannot see margins at left and right, margin top-bottom can be seen. This problem can be more explained by the image below which is of a Lollipop Device:

**image:2**

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

I am applying the theme :

```
 <style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
    <item name="android:colorPrimary">@color/colorPrimary</item>
    <item name="android:colorPrimaryDark">@color/colorPrimaryDark</item>
    <item name="android:colorAccent">@color/colorPrimary</item>
    <item name="android:windowActionModeOverlay">true</item>
    <item name="android:windowContentTransitions">true</item>
    <item name="android:windowNoTitle">true</item>
    <item name="android:actionModeBackground">@color/colorPrimary</item>
    <item name="android:windowContentOverlay">@null</item>
    <item name="android:textColor">@color/myTextPrimaryColor</item>
    <item name="android:windowAllowEnterTransitionOverlap">true</item>
    <item name="android:windowAllowReturnTransitionOverlap">true</item>
    <item name="android:windowSharedElementEnterTransition">@android:transition/move</item>
    <item name="android:windowSharedElementExitTransition">@android:transition/move</item>
    <item name="android:typeface">serif</item>
</style>

```

Please help. I stuck here for last 4 days.