In the world of programming, anything is possible (I've been told by many developers).
In your code, you simply need to add the following code in the onClick method:
LinearLayout layout = new LinearLayout(MainActivity.this);
layout.setBackgroundColor(Color.parseColor("#135517"));
Setting background is just an example of what it's capable of achieving. One thing I would recommend you to do is to position it properly to ensure it fits the hierarchy accordingly.
For example:
RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) viewToLayout.getLayoutParams();
params.addRule(RelativeLayout.BELOW, R.id.below_id);
With this piece of code, you are creating a new params layout and add a rule to the layout which in this example is coded to position below another element.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.