I need to use a custom view in order to show an animation. Right now I have a layout with a button, and when that button is pressed, the custom view is set and the animation starts inmediately. The problem is that the button should be on top of the custom view so the user can see the view before the animation starts.
I have searched and I think it can be done by using a FrameLayout, but I don't know how to implement a custom view inside a FrameLayout. Can anybody help me?
Make a Layout with the stuff you want inside the FrameLayout such as a LinearLayout, Relative, etc..
Inflate that Layout using a inflater and them place the layout on your FrameLayout
Or you can inflate your customView and add the view to it.
View myCustonView = (View) inflater.inflate(R.layout.mycustomview);
myCustomView.addView(myButton);
Related
I have Two children on a FrameLayout, a view pager and a backround view
I add the background view as a second child , so it's supposed to be on top of my view pager.
The problem is I can still scroll my view pager despite of having another view on top of it.
the structure is :
<FrameLayout>
<DrawerLayout>contains view pager and content</DrawerLayout>
<LinearLayout></LinearLayout> -> this is where I add my view as a black background
</FrameLayout>
How do I disable the input and listener for the first child of the framelayout or is there an easier way of doing this?
Tried setting the elevation, and bringViewToFront(), but those aren't working.
Thanks
You can disable focus on framelayout and enable focus on child views. See if this helps you.
framelayout.setFocusable(false);
framelayout.setFocusableInTouchMode(false);
Set focusable to true for drawerlayout and linearlayout. Hope this helps.
I think I have found the answer.
Been lurking on stack overflow a bit and found the answer on this
Overlaying a view does not disable actions on underlying view
It is stated by nizammoidu that an underlying view (behind view) will instead intercept the touch event if the front view is not consuming the touch event.
So the solution is by giving the top view (in my case LinearLayout)
clickable parameter to true
android:clickable:true
or
view.setClickable(true);
I had prepared a custom view now i want to place that view with some other basic views through a custom layout. I dont know much about custom layouts. How can I arrange these views programatically in custom layout and then how can I inflate that layout.
Thanks in advance
I have a LinearLayout which contains several views. When I add a new view to the linearlayout programmatically, I want it to fade out the last view on the right, and to move in the new view from the top (translateY). What is the best way to implement this intro/exit transition that works from API 14+?
I am adding view to linearlayout, when i add views the the previous view get shifted. But what i want is that the shifiting of views is done with animation. Please help.
You can do it by using View Flipper , try this Link
In my activity I have a scroll view which contains a linear layout that has many views. Is there a way I can display a specific view (from the linear layout) when starting this activity? By default this view is hidden, so I must scroll the scroll view to make it visible.
Scroll the view to the view you want to show:
scrollView.smoothScrollTo(0, specificView.getTop())
See Is there a way to programmatically scroll a scroll view to a specific edit text?
You can use:
setVisibility(View.GONE);
see setVisibility for details