Creating custom "instruction tips" - android

I would like to create a view which i could place beside a specific function on the screen as instruction. This "instructiontip" thing will show automatically according to some rules.
The advice I'm seeking is about the way to put such a view anywhere on the screen above all else and not affected by parent type, fx. if added dynamically to a view which root layout is LinearLayout (vertical), I of course don't want it to be places under the last element. I'll place it using coordinates on screen and would expect it to show exactly there.
Here is a design shot for impression:
I keep thinking that there must be a better way of doing that then just adding it and hoping it will show in place.

Activity.AddContentView is a good way of adding such a view above everything else without affecting whatever is beneath.
The only downside is that you can't remove this view after you added it.. but you can hide it if you need to.

Related

how to add search result on top of other views

I have an EditText in my layout which is used to get the search query from the user. I want to show a LinearLayout bellow it when user enters some characters and fill it with the results (This layout should appear after entering at least N characters). But I don't know how to show this layout?
I thought of putting the whole layout shown in the activity inside a FrameLayout and add the view when required, but there will be two problems:
The view will be added on the top left of the screen.
If I want to move it with adding some padding to it, all the area will correspond to the click event.
To explain what I want more, please take a look at this:
I hope this link will help you, you need to use AutoCompleteTextVIew
http://www.javatpoint.com/android-autocompletetextview-example
https://www.codeofaninja.com/2013/12/android-autocompletetextview-custom-arrayadapter-sqlite.html
These is two approaches for your case.
Use AutoCompleteTextView
Use android-popupwindow.
The former is easier and more acceptable, however if your want to customize the layout of the resulting search, for example arranging them in a gird view, you may what to use the latter option.
Although, AutoCompleteTextView internally uses the latter option.

Need suggestions for dynamically creating views in android

I am going to start one app where my activity page will contain "n" grouped views. Grouped view means "collections of views (i.e. One group can have TextView+Button+ImageView)". So the page will have "n" number of such grouped views.
I need suggestions like what would be the best practice to implement this. I could think of below ones:
1) Should a ScrollView be used (Then I will have to create groups in runtime and place one under another)?
2) Or a ListView be used (Then how can I accommodate the height of each row as grouped views height may differ from each other?)
Or is there any other way I can go along with?
Appreciate the suggestions and any sample examples if have. Advance Thanks.
Both options would work, it really depends on your use case.
Place a vertical LinearLayout inside of a ScrollView and add your grouped-views to the LinearLayout. I would recommend this if you have a relatively small number of such views (not necessarily a fixed number, but small enough that you wouldn't have to scroll many "pages" to see them all). Make sure the ScrollView has android:layout_height="match_parent" and the LinearLayout has android:layout_height="wrap_content".
If the number of grouped-views is not small, you could use a ListView and make an Adapter for it. This lets you take advantage of ListView's automatic view recycling when items get scrolled off screen.
For either case, make an XML file for just the grouped-views. In code, you would get a LayoutInflater object (usually by calling Activity.getLayoutInflater()) and call inflate(R.layout.your_grouped_views, null). If using the LinearLayout, you would add it in code with one of the LinearLayout.addView(..) methods; if using the ListView, your adapter would return the whole thing from getView(...).
create one xml layout containing the constant elements of your group view.
in you main xml layout which will be the contentView of your application, put a ScrollView and a single LinearLayout.
then in the program inflate as many views of your group view as you want.
For your answer i want to give you referance of this website, on this website you can learn create dynamic view in android...

Replacing views dynamically without changing activity

I would like to know how to go about doing this small problem that I am encountering while making a video player app.
On clicking the first control(the rectangular icon) in the above image the following view must be displayed instead of it which I am quite unsure as to how to do it. Here is what it is replaced by
Also please note, by any chance the activity should not be changed. I have been able to design the views individually but having problem changing them at runtime when user clicks. Could someone go about explaining as to how it can be done or provide some suitable links to achieve my goal. Thanks.
For something as simple as this you can just change the visibility of the views.
view.setVisibility(View.INVISIBLE)
Or the more effective:
view.setVisibility(View.GONE)
Do that on the views you want gone, I suggest a wrapper class. It's either this or changing the contentView as describded below.
this.setContentView(R.layout.newLayoutToUse);
However, I have a feeling there is a better way to do what you want. It's overkill to load a complete new layout if you just want to change the image of some buttons or imageviews.
This might be a stupid solution, 'cause i'm terribly tired right now, but why not use the bringToFront() method on the View that you want to display in the front? Display them both in front of each other, maybe in a RelativeLayout, and then swap between them as you wish.
They are small objects, so don't consume memory. I don't see why this shouldn't work.
OR
Place them above one another, so they overlap and then make the above view visible/invisible depending on which one you need to display.
OR
just remembered I read somewhere that you can scroll through a ScrollView automatically from code. So display both Views in a ScrollView in succession and when pressing the button or whatever, you scroll down to make the next menu visible. When pres back, you scroll up to make the previous thing available. Should work, and might also make a nice animation between changing of the menus.

Which layout can provide free drag and drop insertion?

I'm using Eclipse graphical layout, and i want to Drag and Drop components to the layout and i want them to stay at the exact position that i dragged them.
Relative Layout is the closet thing but it changes the location of the components after couple insertion.
thanks.
Rami.
i want them to stay at the exact position that i dragged them.
No, you don't. Android devices come with screens in many different sized and resolutions, so fixed positioning of components is a recipe for making the application unusable to users with a different screen that you.
The point of layouts is that they can adjust to different screen sizes. Learn to use them properly.
You're looking for AbsoluteLayout, but it is deprecated.
RelativeLayout is the way to go, just pay some attention to the hints drawed on-screen when you place your elements.
You should be careful also to avoid circular references otherwise your items will be scattered randomly over the layout. (Example: Textview A on right of TextView B; TextView B on left of TextView A)
Be careful also when you change your element's id because the IDE does not update automatically all the references and thus your layout gets scattered again. When you update an ID you must update all its references in the XML file by hand.
Actually absolute layout is the answer what u want ,but that is deprecated.Relative layout does what you want.But it arrange its child based on parent position.If you drag a text view ,then other view will depend on this text view.If you have inserted 2 view,then third view will depend on the parent(2 views).But in between if u disturb any of the view ,it may affect other views.So do things systematically
In Java what we can typically use is GroupLayout. You may see what the equivalent is for android.

Problem with Android drag - drop UI development

I am newbie to android so this might be one of the dumbest question you face.
I am developing UI in Eclipse through drag-drop.I have added many elements in one screen now
the window where you drag-drop UI elements is not growing/scrolling beyond a capacity.
So I am not able to see newly added elements.
Please check image for more details..
You can observe elements after Storage Position are not visible.
How to check other elements or cant we add elements beyond a certain number/size ?
~Ajinkya.
You can add as many elements as you want. I can see a bunch of LinerLayouts for each of your items, but each linear layout is one row and has a horizontal orientation, correct? I'm not sure what you have as your overlying view, but make sure that all of those items are inside of a LinearLayout with vertical orientation. You can wrap that in a <ScrollView> to add a scrollbar to it. Here is a Scrollview example
Side note: Also, the drag and drop is nice to look at, but I've always had a better experience directly editing the xml, even if I started creating the layout with the GUI. It's easier to tell what is going on with each element and make changes. It's best to check the way everything looks in the emulator too, sometimes it can look different than in the GUI editor, especially if items are put into your interface programmatically.

Categories

Resources