I'm looking for a way to display a "stand-by screen" for within my app.
I have a main activity with a fragment and I've added a button to the side of the main activity to trigger when this "Stand-by" screen should show, which will be nothing more than displaying a picture.
I have already tried changing the content view, it works for setting the screen but when I try set it back to activity_main it throws an error about being unable to inflate the fragment.
Which lead me to try creating a linearlayout view programmatically (spelling?) and setting this view visible with setvisibility but this doesn't work either.
I have also looked at AlertDialog but I don't think this is the best way to do this.
Thank you for reading
The easiest? add an ImageView or any View with opaque background as the last element of your layout, with dimensions MATCH_PARENT / MATCH_PARENT and Visibility GONE.
When you want to show it, just call view.setVisibility(View.VISIBLE) , or view.setVisiblity(View.GONE) to hide it. It will come up above the rest of elements, which will be hidden under its opaque background.
View view=findViewById(R.id.yourSplashId);
show
view.setVisibility(View.VISIBLE);
hide
view.setVisibility(View.GONE);
I see in your question that you tried this approach and it didn't work. Maybe that View you generated was behind the fragment?
You can also put your Fragment + splash inside a ViewFlipper
<ViewFlipper>
<fragment>...</fragment>
<FrameLayout>
<imageView>
<progressbar> .. etc
</FrameLayout>
</ViewFlipper>
this has the added benefit that you can setup animations for transitions etc.. In this case:
ViewFlipper myFlipper=findViewById(R.id.myFlipper);
myFlipper.setDisplayedChild(0); // fragment
myFlipper.setDisplayedChild(1); // splash
and
myFlipper.setInAnimation(AnimationUtils.loadAnimation(v.getContext(), R.anim.left_in));
myFlipper.setOutAnimation(AnimationUtils.loadAnimation(v.getContext(), R.anim.right_out));
Related
I have two layouts, manageLayout and mainLayout. They have constraints to the parent on all sides. I need in a one time have manageLayout on the top of mainLayout, and on the other time mainLayout on the top of manageLayout. Of course, there is sense in using visibility=gone on one of them, but i need one layout on the background of another. Problem: layout on the background handle events from top layout. How to make lower layout(and his elements) untouchable when another layout is risen?
Layout tree image:
LayoutTreeImg
Code sample, where i want to disable communications with lower layout: https://pastebin.com/PeL7u3YD (not only isSaveEnabled=false had no effect, also isEnabled=false had no effects too)
If you just need an explanation.
Once you've initialized both your views for mainLayout and manageLayout, you will need to set an empty onClickListener on both of them. Basically, layouts should get the click but do nothing. This way you can block the layout and widgets underneath the view on Front from getting clicked.
Now for for switching view to front maintain a boolean to know which view is on the front and on your button click set the other view bringToFront() (Or try some other ways mentioned here if you want) and don't forget to switch the boolean value.
Let me know if this works for you or you have any issues regarding this.
According to my perception, you can make lower layout setEnable(false). I hope it will work.
Had a question about making part of a View Always-On-Top. Please see the Groupon picture below. The black window at the bottom where it says "From $29" & "Buy!" is always on top of the activity page. Meaning the rest of the page is scrollable above that black window at the bottom. Please note I only want this activity to have an Always-On-Top
How do I make a portion of the activity Always On Top? And what kind of layout did you think they used for Groupon? I was just going to make a RelativeLayout and layout_alignParentBottom="true".
You could probably get away with having a vertical linear layout with two children. The first one a scrollable area and the bottom a view with whatever it is you want to be 'on top'. Since there's no transparency there's no visual difference between having the black view as always-on-top and having one view on top of the other (in the y-axis, not z-axis). Plus, if you do it this way you can reach and see the bottom of the scrollable view's content.
To the best of my knowledge, the best way to do this is by implementing a BaseActivity with this View, and have all your activities extend this activity instead of the standard Activity.
I found this code to make a sliding menu like facebook app. He (who wrote this code) used a FrameLayout to contain 2 views and used TranslateAnimation to show/hide menu. He used setFillAfter(true) to keep position of view. In onAnimationEnd, he used view.layout(left, top, right, bottom) to ensure that views are in correct position.
I modified this code to use with 3 views: leftView, centerView and rightView (Each view in my case is a LinearLayout) like facebook and found a problem: when activity is show leftView (and a part of centerView), if I click an EditText in leftView and soft keyboard is shown, it return to centerView. Similarly, it happens when I click on an ExpandableListView and Childs is shown.
Can anyone help me please?. Here is [my code](https://dl.dropbox.com/u/38205395/TestErrorSlidingActivity.rar).
Thank you in advance and sorry for my poor English!
Your problem is that the keyboard retriggers the measurement/layout pass of your FrameLayout.
At this point the layout you manually called gets replaced from the FrameLayout original layout.
To avoid this you have 2 ways:
1) Do not use a FrameLayout (define your own extension of the viewgroup or extend FrameLayout overriding all the methods regarding the measurement/layout of the children)
2) Do not call layout after the animation but rather try using setMargin on your children (if possible)
Obviously the best way would be the first one.
Try using android:windowSoftInputMode="adjustNothing" for activity in manifest.
Worked for me :)
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...
Friend's
I need help on loading the content alone in my page without going to new page when i selected the scroll menu.
**> I have an
1. header layout and
2. framelayout in another xml file have declared Listview and it
also have tabhost
**and also have gallery view for scroll menu.
3. content list in another xml file.****
when i selected the scroll menu i need to load the list content alone in that activity i suppose not to load whole header and and redeclare tabhost in next that scroll menu selected activity.
Thanks in advance.
I achieved this effect by having everything defined in a single xml file with multiple TableLayout views stacked on top of each other within a Merge view. In order to "load" a view, I change its Android:visibility tag from "gone" to "visible". Since you want your second view to not obscure the header, you can put a buffer (margin or padding) that offsets it from the top of the screen. The background color of this top TableLayout would have to be android:background="#00000000" so that the alpha channel is zero and it is transparent.
If anyone else has a more elegant approach, I would be interested to know as well, but this suites me just fine. The only downside I see is an extra large XML file.