I want to get result image pragmatically.
When the user submitted answer the view "Option" text should automatically set on top of the screen in ScrollView. The whole view is inside the ScrollView.
You might have the "Option" TextView inside the ScrollView with a visibility set to gone in your layout XML file. When an answer is selected, change the visibility status of that TextView to View.VISIBLE programmatically.
Hope that is clear. Please let me know if you need to anything else.
Related
I have two TextView in my android code, one over other. The lower text view do not have onCLickListener set but the other TextView has, and also lower TextView is set invisible. The problem is that the upper text view do not respond on click as long as it is placed over the other text view. Please tell how can I solve this issue? I can not change components' positioning because of some reasons.
Seems like a z-index problem to me: your invisible view is placed on top of the visible one, which does not receive the click.
The click is received by the invisible one, that does nothing.
I've never experienced that, but you could try to define the visible view after the invisible in your xml file.
If it does not work, I believe that here can be something that could help you.
Make sure that the textview is gone not just invisible:
Eg.
textview.setVisibility(View.GONE).
This will make the textview leave instead of just making it invisible.
Apply following line on desired TextView and then check onClick event.
yourTextView.bringToFront();
I am trying to code a layout, but I do not know well how to approach it.
Initially I have the following:
When the user click in this View, I need to show:
I thought I will need a Spinner, but the content that is shown when the user click is not a list but a set of Views (In this case, it will be a LinearLayout with a Spinner and a EditText).
I am a little lost, what would be the best approach to achieve this?
Do I need to implement a CustomView?
Sorry if it is a dummy question, but I can figure out how to code this Layout.
I think the best approach would be to make a LinearLayout in wich you can place you Spinner and your Search EditText and set this LinearLayout ViewGroup setVisible(View.INVISIBLE).
Then when you click on the "registra alimento" View set the LinearLayout below to setVisible(View.VISIBLE)
To fade it in:
Animation in = AnimationUtils.loadAnimation(this, android.R.anim.fade_in);
viewToAnimate.startAnimation(in);
viewToAnimate.setVisibility(View.VISIBLE);
Take one Linear layout add Textview of Registrar alimento than set linear onClickListener with visibility of Spinner and edittext.(Also maintain flag for visible invisible )
How can i cover the screen by TextView i written Below but it does not work
I want the Facebook buttons to show sometimes i dont want them to show i just want to show a
Thank You for your help
Either re-order your RelativeLayout to place the element you want on top at the bottom of the layout list, or use a FrameLayout. A FrameLayout will allow you to overlay elements.
See here:
Android overlay a view ontop of everything?
The problem here is very simple. You are adding your TextView first and then you are adding ImageView. Both these are set to match parents width and height but since you are adding ImageView later its z-index is greater than that of TextView.
To confirm these just remove the ImageView and then check.
Hope this helps :)
In my app I want to have a button that if the user clicks it
than a new layout is opened within the current (acually the main) layout.
the new layout should not fill all of the screen and parts of the previous layout
should be grayed out.
Any ideas on how to do this ?
You can show a hidden layout within your button's onClick event by calling
view.setVisibility(View.VISIBLE)
You can also fade out view elements or whole views with
view.setAlpha(75);
view.setBackgroundColor(Color.GRAY);
Note that "view" in the first example is your layout element.. LinearLayout, RelativeLayout, etc. and in the 2nd example, "view" is the element(s) you're trying to gray out.
Follow the answer of SBerg413. And for more information. you can take the relativelayout for the part that you want to hide and display on the button click.
And as like SBerg413 answer. you can hide the respective layout and show the layout you want to display.
Hope it will help you.
Thanks.
you can use a ViewFlipper to achieve what you want, position the viewflipper where the child views should fit (part of the screen you say)..
Inflate the rest of the "child" layouts from other xml, add them to the flipper and switch between them when you want...
I have a UI that has a handful of text entries that might be needed by the user. The users selects the type of entry from a spinner. when the selection is made I change the visibility of some edittext controls and change the label that goes with it.
The problem is the space where the edittext was is now blank and the screen layout looks screwy.
I put all of this in a table, hoping I could hide a row, but that didnt help either.
Any ideas short of make a new class for each one?
Instead of setting the visibility to View.HIDDEN, set it to View.GONE. From the description for View.GONE:
This view is invisible, and it doesn't
take any space for layout purposes.
Use with setVisibility(int).
just make sure u use SetVisibility(View.GONE)