I have a problem with Views
, but only on API 16 :-(
There is a CustomView
, which looks like this:
<LinearLayout
android:id="top_container"
android:orientation="vertical">
<LineartLayout
android:id="labels"
android:orientation="horizontal"/>
<FrameLayout
android:id="content"/>
</LinearLayout>
Now what happens in code is that on onLayout()
of the view, if changed==true
, I query an adapter object for a set of LabelViews
and one ContentView
. I put the labels into the labels
LinearLayout
and the content into content
FrameLayout
.
It works great, except on API 16, where the labels and content are queried from the adapter, added to the respective containers, but are not shown! :-( Moreover, the containers actually resize correctly, so the Views
have measured dimens, just no visual data displayed :-(
By trying several solutions I have noticed that if I add the content View
with LayoutParams(LayoutParams.MATCH_PARENT, XX)
where XX is an actual number, it will show the views...
Any ideas? Was there some change in the ViewGroup
logic after API 16 that could have caused that?
EDIT:
This is how the invisible child view shows in tha output of adb shell dumpsys activity top
(in the above structure it is the direct child of top_container
):
android.widget.LinearLayout{42960190 V.E..... ... 0,0-0,0 #7f0f036f app:id/labels}
com.example.view.pricebox.CheckoutLabelView{42614a18 V.E...C. ... 0,0-0,0}
android.widget.RelativeLayout{43118438 V.E..... ... 0,0-0,0}
android.support.v7.widget.AppCompatTextView{4310feb8 V.ED.... ... 0,0-0,0 #7f0f0371 app:id/label_name}
android.support.v7.widget.AppCompatImageView{421b8080 V.ED.... ... 0,0-0,0 #7f0f0372 app:id/label_icon}
com.example.view.pricebox.CheckoutLabelView{4261f8a8 V.E...C. ... 0,0-0,0}
android.widget.RelativeLayout{4207e4e0 V.E..... ... 0,0-0,0}
android.support.v7.widget.AppCompatTextView{43129410 V.ED.... ... 0,0-0,0 #7f0f0371 app:id/label_name}
android.support.v7.widget.AppCompatImageView{4205d938 V.ED.... ... 0,0-0,0 #7f0f0372 app:id/label_icon}
android.widget.FrameLayout{42960870 V.E..... ... 0,0-0,0 #7f0f0370 app:id/content}
com.example.view.pricebox.checkouts.CheckoutView{41db1fd0 V.E..... ... 0,0-0,0}
android.widget.FrameLayout{42d73308 V.E..... ... 0,0-0,0 #7f0f0367 app:id/content_button_container}
android.support.v7.widget.AppCompatButton{4224d3e0 VFED..C. ... 0,0-0,0 #7f0f0368 app:id/content_button}
android.widget.ProgressBar{41ab5288 G.ED.... ... 0,0-0,0 #7f0f0369 app:id/content_button_loading}
android.support.v7.widget.AppCompatTextView{4273cd08 V.ED.... ... 0,0-0,0 #7f0f036a app:id/content_label1}
android.widget.RelativeLayout{43100b20 V.E..... ... 0,0-0,0 #7f0f036b app:id/content_stuff_container}
android.support.v7.widget.AppCompatImageView{42554f58 V.ED.... ... 0,0-0,0 #7f0f036c app:id/content_icon1}
android.support.v7.widget.AppCompatTextView{423beee0 V.ED.... ... 0,0-0,0 #7f0f036d app:id/content_icon2}
android.support.v7.widget.AppCompatTextView{41e02ed8 V.ED.... ... 0,0-0,0 #7f0f036e app:id/content_label2}