Scroll View in Android shows up when I scroll it - java

I have a Scroll-view layout, which is, say my main menu, when user clicks on an item I want to make my menu disappear, and show the contents that user wants!
everything works fine, I use this code:
mainMenulay.setVisibility(View.Gone);
but, when I touch the screen, and swipe the screen (like scrolling when it was actually visible), where the main menu was located, the scroll-View show up in an unwanted buggy way !
its not functional, but it shows up !
I have fixed this issue with Z Order and defined a background and have brought it in front of the Main Menu and it wont show up, but I'm curious to know what's wrong, how to avoid it ?!
If you have questions about How I defined the Scroll-View, well. it looks like this:
<ScrollView
android:id="#+id/main_menu_lay"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginBottom="61dp"
android:layout_marginTop="65dp"
android:visibility="visible" >
Thanks in Advance :-)

I've seen other people with the same problem, but only when an animation i used to hide the view.
android View with View.GONE still receives onTouch and onClick
and
Unable to make view completely GONE after using TranslateAnimation
Probably, you can take a look at
View.setClickable();
and
ViewParent.requestDisallowInterceptTouchEvent()

Related

make buttons behind view not clickable

I have a linear view in front of some buttons with a background and my problem is that I can still click the buttons on the back of the view even though I can't see them. is there a way I can make the view "solid" so I won't be able to click through its background/borders?
I am not sure why you are not just deleting the buttons but one way you can go about it is disenabling the buttons from your java file using
myButton.setEnabled(false);
or in your xml file using:
<Button
android:enabled="false"
/>
Solved! I just made the view clickable thus making it "solid" and stopping anyone from clicking stuff behind it

Android: Using both adjustPan and adjustResize doesn't work but I need both

I haven't officially decided if I want to head this route or not but I have an adview in my XML document. The XML document contains a Relative layout that contains a ScrollView and and Adview. The Adview sticks to the bottom of the relative layout while the scrollview is everywhere else.
When a user focuses on an edittext inside of my app, some of the page would be cut off. I fixed that by adding:
android:windowSoftInputMode="adjustPan"
But then the problem became that my AdView gets cut off everytime the user has the keyboard open. So to fix that issue I changed the Android Manifest to:
android:windowSoftInputMode="adjustResize"
Which kept the AdView on top of the keyboard, but now the Adview covers some of the content on the app. I was wondering if there was a way to have my app content not be covered and keep the AdView above the keyboard when it appears?
I have tried this but it did not work:
android:windowSoftInputMode="adjustPan|adjustResize"
Not sure if I actually want to go that route, I just want the choice. It kind of looks annoying in my opinion.
You can't set adjustPan and adjustResize at the same time. They mean completely different and conflicting behaviours. They only affect how your root view behaves when the keyboard appears or disappears.
adjustPan means "When the keyboard appears, if a view behind the keyboard gains focus, move the view up so that the user can see it" but it doesn't allow the user to move the view around themselves.
adjustResize means "When the keyboard appears, change the height of the view to fit above the keyboard". That doesn't mean that your view will adapt correctly to fit in that space - that's your job.
It sounds like what you're trying to do is have a ScrollView above the advert which is stuck to the bottom of the root RelativeLayout view. In your case, you definitely want to use adjustResize to cause the RelativeLayout to resize to a shorter height. This in turn moves the advert up to the top of the keyboard as you described. Then you have to make sure that the main ScrollView is always above the advert and not somehow tucked behind it. You probably want a layout that looks something like this:
<RelativeLayout
android:layoutWidth="match_parent"
android:layoutHeight="match_parent">
<ScrollView
android:layoutWidth="match_parent"
android:layoutHeight="match_parent"
android:layoutAbove="#+id/advert_view">
<!-- Your scrolling views go here -->
</ScrollView>
<AdvertView
android:id="#id/advert_view"
android:layoutWidth="match_parent"
android:layoutHeight="wrap_content"
android:alignParentBottom="true" />
</RelativeLayout>
Note that the ScrollView says it wants to be the height of the parent, but laid out above the AdvertView. This will mean it isn't behind the AdvertView at the bottom edge and you'll be able to scroll to anything that exists inside the ScrollView.

Android Vertical Switch Widget

Using android, I'd like to get a vertical switch widget implementation in place. As far as I can tell, it looks like switches only have a horizontal orientation. I'd like to have something like the following:
After looking through the threads here and searching google, I have yet to find something that can give me this. Everything I search for gives me the horizontal implementation only.
so I can generate your typical horizontal switch
<Switch
android:id="#+id/switch_button"
android:layout_width="130dp"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/label"
android:layout_gravity="center"
android:switchMinWidth="130dp"
android:thumb="#drawable/switch_selector"
android:track="#drawable/track_selector" >
</Switch>
but there doesn't seem to be a good way to set the orientation. I know that the question is a bit high level. Is there some attribute that is immediately available that will allow me to have a vertical switch? Or will I have to create a custom switch and possibly modify the onDraw method so that it is flipped vertically? Any help is appreciated. Thanks.
Try android:rotation="90" like this:
<Switch
android:id="#+id/switch_button"
android:layout_width="130dp"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/label"
android:layout_gravity="center"
android:switchMinWidth="130dp"
android:thumb="#drawable/switch_selector"
android:track="#drawable/track_selector"
android:rotation="90">
</Switch>
There is no quick attribute for vertical orientation.. Sorry :)
First you can look at the code of the switch and see if you can copy and manipulate it.
Second you can just implement your on. Have a layout with a button inside it. use onTouchListener to slide it from side to side. No need to use "onDraw".
Try toggle button witch graphics and use pictures like this You included in Your post. Here is example of such toggle buttons: Toggle button using two image on different state

Layout And Views Visibility on app

I was testing my android app on device by enabling device show layout boundaries in developer option on device.
I check my listview with inflated view with textviews , rating bar and other views clearly seen as shown below .
later I tried twitter app but surprise to see only single view ???
anyone know how to get twitter like single view on listview ??
anyone know how to get twitter like single view on listview ??
Each list item is a single custom View object, not a ViewGroup or layout. Essentially, all the content is drawn directly onto the Canvas in onDraw() rather than relying on child ImageView and TextView elements. Images can be drawn easily enough by calling Drawable.draw() or Canvas.drawBitmap() and text is typically drawing using a Layout.
Additionally, this means all touch events are handled directly inside onTouchEvent() to handle taps on the lower icons and/or the avatar image, so there are no click listeners.
Edit: Here's a quick 30 second example that should be enough to get you started: https://gist.github.com/devunwired/8704007
They are probably using the include tag to include another layout file
you can do the same thing if you make your list_row_item layout something like this:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width=”match_parent”
android:layout_height=”match_parent”
>
<include layout="#layout/another_layout"/>
</LinearLayout>
The benefit to doing this is that you can swap layouts on the fly, perhaps even using a server side changes, rather than having to issue a software update

Creating an overlay activity

I am trying to create a overlay activity which is sitting in a corner of the screen taking a very small portion of the screen, while the rest of the screen is interactive that is I tap on anything that is displaying on rest of the screen. So far I am unsuccessful in obtaining my goal. I have added these properties to my window but they don't seem to work.
hello.xml:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="50dp"
android:layout_height="match_parent"
android:orientation="vertical"
android:id="#+id/tepp" >
</RelativeLayout>
What can I do to solve this problem?
From what I can remember, only one Activity can be active at any given time. So while that small Activity in the corner is running, the other activitys will be paused and you wont be able to interact with them. You should try using a Fragment instead. You can have multiple fragments visible at the same time. Although I believe that only one Fragment can be active at any given time like an Activity, when you click on different fragments, the one you click on becomes active and you can interact with it. This might help you achieve what your looking for.
i don't think that there is such a thing "an overlay activity" .
however, instead of using an activity, you could make the view on top, like i've shown here . when the user touches it, you would need to decide what would happen, and if you need to expand its size to be larger to show something else to the user...
btw, if all the activity does is to create an on top view, you can call finish() right at the end of the onCreate() method. also you can avoid using setContentView in case you inflate the view anyway...

Categories

Resources