margin or padding not working using <merge tag android

Viewed 3702

I am using merge tag in custom view and trying to set layout_marginTop or paddingTop on parent view, but doesn't work. Here is my code file name: my_view.xml

<merge
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android_layout_marginTop="17dp" >  // This margin is lost!
    // content here  ...
</merge>

So in My custom view file, MyView.java, I just inflate this my_view.xml. But the android_layout_marginTop information is lost.

public class MyView {
    private void initViews() {
        View view = LayoutInflator.from(context).inflate(R.layout.my_view, this);
        // get rest views
    }
}

I have tried to set the margins and paddings in the code using LayoutParams, but still not working. Your help would be much appreciated!

1 Answers
Related