This question already has answers here:
Closed 11 years ago.
Possible Duplicate:
add and remove views in android dynamically?
In Iphone, the view is added or remove by using addsubview or removefromsuperview.
What about in Android, how do you add or remove a view?
fundamental questions, I am trying to clear up my concepts.
thanks
You seem to understand programmatically adding and removing views in iOS
In android, you cannot necessarily add a view to a view. You will need a subview of the Class ViewGroup (RelativeLayout,FrameLayout...) that you can add views into.
You can use
void android.view.ViewGroup.addView(View child)
void android.view.ViewGroup.removeView(View view)
There are more ways to add and removeView, but the important part is that you look up the reference for ViewGroup. Android layout is a whole different cup of tea compared to iOS layout.
Related
Two years after that this question was asked, I want to know, if in the new versions of Android, there is a simple way to do it?
Please use this :-
https://github.com/lupidan/PopoverView
I used this. It extends a Relative Layout and Create a PopOver. I was talking about this only
This question already has an answer here:
Should I inflate a layout or programmatically create it?
(1 answer)
Closed 9 years ago.
I've simple dialog with only one ImageView, and im using it frequently in my app, and Im wondering what is faster to load and showup, create layout in XML or make the same thing in code.
EDIT
I ask about theoretical knowledge in this point, and I cant find any useful info about that on Android Dev sites.
Theoretically in my opinion, coding the layout is faster than inflating it from xml, because inflaters need to map the layout by it self, and link id's to each other, but in code you will give the viewgroup (lets say) the reference of the view it self, there is no need to lookup it in the xml.
don't forget the step of converting the xml into java elements (views)
No difference, but if you have only one imageview make this layout in code
For performance, there is no noticeable difference.
But for maintainability you want to separate functionality and layout, hence it is recommended to use the layout XMLs.
No one is necessarily faster.
It will be the easiest to define the layouts in xml though, and the xml option is there as a way not to have to define buttons and ui components in java.
Also, if you define views in java, you will end up adding them to your blank xml layout's viewgroup
( ei. adding your button to the layout)
This question already has answers here:
Closed 11 years ago.
Possible Duplicate:
How do you rearrange buttons where you want them in Eclipse?
Hey guys I am having trouble with placing my buttons in my XML layout. I already have a background and was just trying to put 3 buttons near the middle and thats where I'm having trouble. I know about center gravity and all that but could you help me? Also, If I made my own buttons can I just import them using the image button thing, or is that not right? Thanks for the help!
You can rearrange elements of your layout by editing the XML directly or by dragging and dropping in the outline view or the graphical layout view (I find the latter harder to do reliably).
To use your custom views, click on the "Custom & Library Views" button in the graphical layout palette, or just type in the fully qualified class name as the view tag in the XML.
This question already has answers here:
Standard Android Button with a different color
(20 answers)
Closed 3 years ago.
I have been looking at these posts:
StateList
, Different states
What I really want is to add an outer-glow or some way to highlight the button onclick versus making different images for the associated states. Is this possible using colors or themes?
Thanks in advance :)
EDIT:
I found a good solution here, not quite the right answer but a good one none the less:
standard-android-button-with-a-different-color
I think you will be better off making an image for the state rather than trying to use software to render this automatically. The software solution will most likely be slower.
what view is this in android, I have seen this in iphone can any one help
the one shown in bottom near footer
These are all custom views or a combination of multiple views or layouts, You can create one easily, Check out the following links
Android UI
Indeed it is a custom view called OperaSwView only Opera has access to that view.
Do you mean ProgressBar?