How to maintain layout attributes on merged custom android view?

You're right about the parameters being lost. To workaround this you can put the style definition for Highlighter in the layout where you define the Highlighter.

E.g.

<yournamespace.Highlighter 
    style="@style/customLayoutStyle"
/>

Years later this is still something that's complicated on Android, but it can be done.

You can do it by using style attribute in your custom view, then setting the style in you theme.

Don't set the style in res/layout/highlighter.xml:

<merge xmlns:android="http://schemas.android.com/apk/res/android">
    <Button android:id="@+id/btnHighlighter" style="@style/customButtonStyle" />
    <TextView android:id="@+id/lblHighlighter" style="@style/customTextViewStyle" />    
</merge>

Then in your custom view:

public class Highlighter extends LinearLayout {
    public Highlighter(Context context, AttributeSet attrs) {
        // The third constructor parameter is you friend
        super(context, attrs, R.attr.highlighterStyle);
        inflate(context, R.layout.highlighter, this);
    }
}

Define the attribute in values/attrs_highlighter_view.xml:

<resources>
    <attr name="highlighterStyle" format="reference" />
</resources>

Now you can set the style in your theme

<style name="YourAppTheme" parent="Theme.AppCompat">
    <item name="preferenceViewStyle">@style/customLayoutStyle</item>
</style>

This way this style will be used by default whenever you use Highlighter.

Usage of your custom view is then like you want:

<com.your.app.Highlighter
    android:id="@+id/highlighter"
    ... />

I have not verified if this works with layout_weight, but it does work with padding, background etc.