I have a pretty complex layout defined in xml
file , now I want to add this layout as a view using addView
or something else.
As layout is pretty much complex , its pretty cumbersome process to write the code for layout and then add it as a view. So is there anyway to load layout resource
and add it as a view.
I want to add the layout into WebView
Use
LayoutInflater factory = LayoutInflater.from(this);
View myView = factory.inflate(R.layout.my_layout_id, null);
then use addView(myView)
U can also reduce this to oneline code;
View view = View.inflate(getActivity, R.layout.my_layout,null);
then add to your view.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With