Inflating/folding out panel in Android - android

I am working on a simple Android application that should contain a webview and two control-panels.
One small control panel should be always visible and the other one should inflate when a special button on the smaller control-panel is clicked.
Implementing the webview is not a problem. But I am not sure which layouts and containers I should use to implement the control-panels on the right side of screen.
Is there a common way to get these control-panels? And which Layouts and Containers should I use?
Here is a picture of how I want to arrange the screen.
I hope someone can help me. Thank you!

See MotionLayout, you can do this with very basic motion layout ,you are going to have contraintset for invisible panel and visible panel.
think of first contraint set ConstraintSetas constraints that you would use when side panel is not there another ConstraintSet when it is there , then you are going to have a Transition with OnClick attributes , and you reference a button in the visible side panel , when that button is pressed motion layout will interpolate between first and second constraint sets. Here is similar example

Related

Replacing a View in Android onClick

I'm still kind of new to android. I'm writing a Tic Tac Toe game as a bit of practice. I'm trying to figure out how to replace views when I click a button. I have 9 buttons in a GridView. When a user clicks one, I want that to change to a non-clickable TextView and back to Button when a user click's the reset Button at the bottom of the screen.. I use a flag to keep track of player's turn so it'll know whether or not place an x or o. Is this even possible or am I stretching here?
You'll soon find that there are really not that many things that are stretching it for Android.
This is certainly possible. For each grid in your GridView, put in two elements - the Button, and the TextView. Change the visibility of each. In other words, you don't actually replace one with the other - you just hide one, and show the other.
So you'd have two items like this:
<Button ... android:visibility="invisible"/>
<TextView ... android:visibility="visibile"/>
And have both of these match_parent, so that they fill each grid and are basically both on top of each other.
To change the visibility in the code:
button1.setVisibility(View.INVISIBLE);
textView1.setVisibility(View.VISIBLE);
I'm trying to give you as little actual code as possible so you play with this and write it yourself, but this should definitely put you in the right direction. Let me know if you need more guidance though.
You can do it two different ways
You can put both a button and a textview in each grid and interchange their visibility when you click on the button. For this, you can set the button and textview properties from the xml layout and you dont have to do much programatically
You can use a button alone and just change the look by changing the background drawable at runtime. Then you can make it unclickable by disabling it or changing its focusable property to false
You can even use an imageview and just change the drawable src and disable it on user click. Android is quite flexible and this is not even a stretch. If you give a little more detail of the specifics you want to achieve, I could advise which solution will be best fit

Sliding drawer looks like semi circle

Android provides the SlidingDrawer by default looks like below image -
Image http://www.gru.at/android/wp-content/uploads/2010/09/s_open.png
Can we customize this SlidingDrawer looks like semi-circle type with buttons included. For, example take a look at below image -
Anyone done the SlidingDrawer like above one. I've googled it. Didn't get any nice solution for this. Anyone has idea/example blog for this?
So make sure you have Gimp and 9-Patch at the ready for a lot of trial and error...
Then what you wanna do is...
Add suitable layout to hold buttons where the current ImageView Handle is, like Horizontal LinearLayout or RelativeLayout
Cut the id of the current ImageView Handle and add it to this new Layout you just added
add your buttons to the LinearLayout/RelativeLayout (you can test it now, the buttons and the handle should all slide open at the same time)
Now add Button listeners for each of the buttons
Set the SlidingDrawer to android:allowSingleTap = "false" (tit for tat, you cant have the single tap option anymore, just the slide)
Use a ButtonSelector.xml to have different layouts for buttons be pressed or not pressed.
This is the hard part. Edit the drawables for the buttons, and handle so that they will fit together nicely if the screen is huge, small, landscape, portrait. I recommend using 9-Patch in conjunction with Gimp.
Pat yourself on the back because you now have a totally sweet custom sliding drawer.
Make sure you post pictures and state any problems or issues you ran into as I have never fully implemented this, but I did get to step 6 to make sure it was possible.
Last but not least, Good Luck...
Thanks for RelativeLayout and FrameLayout These layouts makes my requirement comportable with what i need. I've done like below steps -
First, i've splitted the full image into three pieces. And, merge these images with FrameLayout And, gave onclickListner to my center of image(Because, it was contain that arrow marks up/down)
And, i've used the Animation for just to open that View as SlidingDrawer
These steps helps me lot.

Android: How can I use the space from objects with visibility GONE?

When I try to make a layout while working with the graphical layout interface in Eclipse (and not the xml) I came across with this problem:
Let's say that my main layout is only a simple button on the bottom of the screen,
when clicked the button opens up a text box that covers most of the screen.
note : I do this be setting the visibility of the text box from GONE to VISIBLE (and the other way around when I want to hide the text box).
Now (the text box is hidden) I want to use the extra space I have and add a button to the main layout.
normally this isn't much of a problem but since I have the text box covering almost the entire screen in the graphical layout I'm having a lot of trouble doing so (and this is just an example, I want to add more complicated things to my new gained space).
What can I do ? in the graphical layout I can't hide an object (like text box or button) and I drag another button to that space I can see/work with it.
set the android:visibility attribute to "gone" while designing the layout
You are going about this all wrong.
You should be using either a new activity or a diloag box to create a textbox that covers the entire screen or a ViewFlipper to create multiple views on your activity.
It appears that you want to do it from one layout so ViewFlipper would be the simplest choice here.
The documentation is available in the usual place:
http://developer.android.com/reference/android/widget/ViewFlipper.html
Some examples can be found at:
http://www.androidpeople.com/android-viewflipper-example
http://android-pro.blogspot.com/2010/09/using-view-flipper-in-android.html
EDIT
Your question isn't very clear so I have tried to give you my best guess from the information provided. Perhaps a diagram of what you are trying to do here might be more easily understood. Though as I stated a new activity or a dialog box might be better. So you could also look at using a dialog method:
http://www.androidsnippets.com/prompt-user-input-with-an-alertdialog

Android horizontal scroll programmatically

In Android, I want to create a particular control which may require to set the location of a component by fixed coordinates.
This is what I want to do. These screenshot are taken from a swing application of mine. I want to clone the buttons on top and their behaviour, into an android application. Basically if there are too many buttons in the menubar, left and/or right arrows appear, and clicking on them will scroll horizontally to access the hidden buttons.
I need to be able to set the coordinates of an horizontal linear layout inside another one, and even to set negative coordinates in order to scroll on the right.
I'm doing this using a null layout in swing. Can I achieve this with Android ?
I'm not sure if an HorizontalScrollView can do this. Could someone point out a good tutorial or something related to what I'd like to do.
I think a HorizontalScrollView can achieve what you intend to do with your Menu Bar. You don't need these "scroll" Buttons, because a user can swipe the menu.
You can nest LinearLayouts together, however you want. if you want to control their flow try to apply margins to them. You can set fixed Coordinates in an AbsoluteLayout, too.
Consider using a gallery? If not gallery, then a child or cousin of it. As far as I know, there is no ViewParent that will allow what your are shooting for.
Hope that helped ~Aedon

creating a custom image based layout on android

Is it possible to create a layout based on (background) images? For example, there is well know app called Appie that uses this picture as a homescreen:
I might be able to recreate the layout with a TableLayout, but this will be difficult to get it perfectly aligned with the buttons in the image. The default layout options make it very difficult, or maybe impossible, to allow for selection of the buttons on the image (especially when the buttons are in an arc-path).
Can anyone tell me how this is done?
I had some issues positioning a badge on the corner of a view. You can check my solved question:
Positioning a badge bubble on the left upper side of a button
About how it can be done. I would do it with a RelativeLayout and TableLayout as you mentioned, but to be completely sure, you can use apktool to see how the xml are done but it might be ilegal to do it.

Categories

Resources