简体   繁体   中英

I can't see my LinearLayout, why?

My Code:

LinearLayout rb = new LinearLayout(this);
int idy = getResources().getIdentifier("rb"+i, "Ressourcen_Reihe1", getPackageName());
rb.setBackground(normalBox);
rb.setVisibility(View.VISIBLE);
rb.addView(imgBtnItem);

I can't see the LinearLayout.
What's my mistake?

Based on the provided code, rb has not been made part of a live view hierarchy. You'll need to add it to a ViewGroup associated with the layout for your fragment/activity somewhere for it to show up.

You haven't added any LayoutParams to the View. Therefore, it takes up no space.

Also, you haven't shown rb being added to a parent layout.

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM