I am trying to inflate a view beneath my layout, but my to layout becomes transparent. Any idea why?
Here is my mainActivity:
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
val rootView = (this.findViewById<View>(android.R.id.content) as ViewGroup)
.getChildAt(0) as ViewGroup
val inflater: LayoutInflater = LayoutInflater.from(this)
val view: View = inflater.inflate(R.layout.view_blueberry, rootView, false)
rootView.addView(view)
my activity layout:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/flContainer">
<RelativeLayout
android:layout_width="match_parent"
android:id="@+id/rlContainer"
android:layout_height="match_parent"
android:background="#ffffff"
tools:ignore="UselessParent">
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/btStartAnim"
android:text="start"/>
</RelativeLayout>
</RelativeLayout>
and my inflated view:
<?xml version="1.0" encoding="utf-8"?>
<View
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#abab"
/>
This is how it looks: if I add more content it's as transparent as that button. Even weirder considering that I've set a white background in my main layout.
Any idea on how to fix this?