Android CustomView is shown twice

Viewed 173

I created a CustomView which I added to the XML Layout. It is all a very simple layout which shouldn't show any problems. Still, what irritates me is that some elements seem to be added twice to the layout (within itself).

The XML looks like this:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    android:id="@+id/activityLayoutRL">

    <world.b2g.b2gether.ui.RadarQuickInfo
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:id="@+id/radarDetailView"
        android:visibility="visible"/>

</RelativeLayout>

enter image description here

The view itself is simply extending a LinearLayout and is initialized like this:

 public void initView(Context context){
    this.context = context;
    LayoutInflater inflater = (LayoutInflater)
            context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    inflater.inflate(R.layout.radar_detail_layout, this);
}

It sometimes seems to change when switching to another build number. I develop for API level 23 but changing to 22 sometimes seems to solve it (at least sometimes)

So I created this constructor

@TargetApi(Build.VERSION_CODES.LOLLIPOP)
public RadarQuickInfo(Context context, AttributeSet attrs, 
    int defStyleAttr, int defStyleRes) {
    super(context, attrs, defStyleAttr, defStyleRes);
    initView(context);
}

The Layout of the custom view doesn't seem to change anything. So even this causes this effect:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="horizontal" android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:id="@+id/radarDetailRootViewLL">

</LinearLayout>

I assume, there might be an error somewhere? Any ideas?

1 Answers
Related