Android How to create a view programmatically

I need to create a view programmatically. Controls (buttons, tags, etc.) And their positions are known only at runtime.

Here I found "Layout Definition Programmatically": http://mobile.tutsplus.com/tutorials/android/android-layout/

but I need to be able to draw components in exact places to LinearLayout, TableLayout, etc. did not help me.

How can i do this?

+6
source share
2 answers

Create your own ViewGroup ; this allows you to manage the placement of each of your children (buttons, tags, etc.) manually. Check out this one from the 2009 google IO event titled โ€œMake Your Android UI Fast and Efficient,โ€ in particular about 43 minutes in advance for more details.

+4
source

I would look at an example of the Lunar lander in the android API examples here http://developer.android.com/resources/samples/LunarLander/index.html . This helped me a lot when creating games and the need to dynamically draw on the screen.

0
source

Source: https://habr.com/ru/post/894016/


All Articles