Create Layout Programmatically in android - issue

前端 未结 2 847
死守一世寂寞
死守一世寂寞 2021-02-20 14:10

I am creating FrameLayout dynamically using the following code

mylayout.java

FrameLayout layout = new FrameLayout(this);
FrameLayout.LayoutParams layoutp         


        
2条回答
  •  情话喂你
    2021-02-20 14:38

    Android Developer - Frame Layout Documentation reads:

    Generally, FrameLayout should be used to hold a single child view, because it can be difficult to organize child views in a way that's scalable to different screen sizes without the children overlapping each other. You can, however, add multiple children to a FrameLayout and control their position within the FrameLayout by assigning gravity to each child, using the android:layout_gravity attribute.

    In your case, you may use layout.setForegroundGravity(int) for the same.

提交回复
热议问题