Hello. It is required to implement an Activity with some markup (Buttons, text fields, etc.) but with a dynamically changing Background (Background), say displaying an animation or drawing a changing graphic. That is, to organize a two-layer Activity, so that all sorts of decorative things take place from behind, and on top of the controls. What means is implemented like? Thanks in advance for any options.
2 answers
Nessesary to use
<FrameLayout ...> <View [Π½Π° ΠΊΠΎΡΠΎΡΠΎΠΌ ΠΏΡΠΎΠΈΡΡ
ΠΎΠ΄ΠΈΡ ΠΎΡΡΠΈΡΠΎΠ²ΠΊΠ°] ... /> <LinearLayout ...> Π‘ΠΎΠ΄ΠΈΡΠΆΠΈΠΌΠΎΠ΅ ΡΡΡΠ°Π½ΠΈΡΡ (ΠΊΠ½ΠΎΠΏΠΊΠΈ ΠΈ ΠΏΡΠΎΡΠ΅Π΅) </LinearLayout> </FrameLayout>
As a View
you can use ImageView
with an AnimationDrawable
or VideoView
or something else.
- As far as I understand,
FrameLayout
can contain only one child element, so one of us is wrong :) - DroidAlex - oneApparently you. Most likely you are confusing with ScrollView or something else - LackOfKnowledge
- And how do you make it so that all children are displayed, and not the last one on top of the rest? - DroidAlex
- Well, you have a transparent background in LinearLayout, respectively, all the buttons and other controls will be visible over the bottom layers - LackOfKnowledge
- Then give a ride :) But it is better to indicate clearly in your answer. - DroidAlex
I will describe the solution (possible), as I see it, although it is not quite clear what exactly is bothering you and what exactly is needed. And so, you create a layout with the main container element ( LinearLayout
or RelativeLayout
). Further, depending on the conditions, you can change the background of either the root element using the setBackgroungDrawable
, setBackgroundResource
or setBackgroundColor
. You can add a view (absolutely any) to the root element and apply animations to it. For aesthetes perversions, you can use OpenGL.
Then you put your controls inside that view. Something like this!
- "put your controls inside that view." From this point on, please. Like this? Can I stick standard Button, Spinner, etc. elements into my custom View? Is there some kind of example in the form of xml markup or is this done in the description of the class of the View-heir? Thank you in advance. - zugzug
- 2Of course! If you inherit your custom view from ViewGroup or one of the Layouts, then you can. For example, here: code.google.com/p/iosched/source/browse/android/src/com/google/β¦ - DroidAlex