I need to limit the click area on the view. For example, I have a full-screen view, but I need only the top of the screen to be clickable, while clicking on the bottom should not give a result, how can I implement this? adding on top of the container doesn't help
You will need to create a click listener ONLY on the view you want to respond.
TopView.setOnClickListener()
BottonView (nothing).
If for some reason, your top View is not independent, just create another view that is transparent, and set a clickListener on that.
Related
So the screen is going to have some textViews and a button, by hitting the button, the layout should change from linear to constraint, vice versa.
these two should have exact same paddings and alignments. I have my linear layout set up, how do I make an extra screen to perform constraint layout?
do I simply hide and unhide components?
or is there a way to overlap the components?
maybe create another layout.xml something like that?
You can make an copy of your linear layout.
Then open the copied new layout in design view, right click the root LinearLayout object in the hierarchy view, select "Convert LinearLayout to ConstraintLayout" from the popup menu.
I don't think it can create 100% same layout, but good luck!
Is there a way to disable clicks on views behind the ShowcaseView (inside the TargetView)? I have a very short tutorial and don't want users to be able to click through to elements behind the ShowcaseView because this interrupts its flow. Is there any way to disable clicking inside the TargetViews supplied to the ShowcaseView?
Create a view temporarily under the ShowcaseView but above anything you don't want clicked. Then call view.setClickable(false) this should prevent clicks from affecting that view or anything under it.
When you are done your showcase, just delete the extra view from the hierarchy.
https://developer.android.com/reference/android/view/View.html#setClickable(boolean)
I have a stack of views shown on top of each other. So at a time only 1 view is shown and others are below the active view. I want to know whether a particular view is active or moved below some other view inside the ViewPart code. Is there any listener which can tell me that the composites of any view are now moved below some other composites of another view?
Also it would be great if can I know through listeners that a particular view is now made invisible.
I have only access to my view code and that is why I have to implement it in that view only.
Stack of views is shown under one Window so the parent shell is same of all the views.
You can use an org.eclipse.ui.IPartListener to listen for events about parts.
In a ViewPart you can use:
getSite().getPage().addPartListener(partListener);
to add a listener. The listener has method for parts being opened, closed, activated and deactivated and brought to the top of stack.
You can also use IPartListener2 which has some additional methods.
I have a fragment in my app that has a scroll view for the signup and login pages. Right now there isn't enough content in the scroll view to actually make it scroll, however when the keyboard appears, it does cover up most of the content in the view. This causes a lot of issues especially on devices with smaller screens, it blocks a lot, and the view is NOT scrollable, so I have to close the keyboard to get to the rest of the inputs.
I need the bottom of the fragments frame layout to be pushed up to JUST above the top of the keyboard, so the keyboard won't actually hide any content, and still allow the scroll view to actually scroll to the rest of the content.
I have seen the usual fix to an issue similar to this, which would to change the AndroidManifest.xml to the following:
android:windowSoftInputMode="adjustResize"
but this will push up the entire page, which includes the footer view I have under and outside of the login and signup fragment layouts. It makes my scrollview smaller and allows for it to scroll, but I need the footer to stay hidden under the keyboard still.
I think a work around to this would be to have override onConfigurationChanged(); in MyActivity that will detect if the keyboard has appeared, and if it has, push the bottom of the framelayout to be JUST above the keyboard, thus making the scroll view smaller, and allowing us to actually scroll. I am not quite sure HOW to do this though.
Here is what it looks like with the keyboard up, blocking the content. This would be okay IF the scroll view was scrollable, allowing me to see the rest of the content, however it will not scroll and the only way to access the content under it is to close the keyboard first.
EDIT
I was able to use the answer below, editing the Android manifest for
android:windowSoftInputMode="adjustResize"
and the first method using the code below
final View activityRootView = findViewById(R.id.activityRoot);
activityRootView.getViewTreeObserver().addOnGlobalLayoutListener(new OnGlobalLayoutListener() {
#Override
public void onGlobalLayout() {
int heightDiff = activityRootView.getRootView().getHeight() - activityRootView.getHeight();
if (heightDiff > 100) { // if more than 100 pixels, its probably a keyboard...
... do something here
}
}
});
I had it adjust my views so the footer would be pushed way down below, then resize the layout holding the fragment to extend down allowing it to be scrollable still.
Okay, here's how I solved it.
The basic idea is that you have to:
Detect whether or not a soft-keyboard is showing,
React. Based on the detected information (is-soft-keyboard-showing), resize your layout accordingly.
There are two ways of achieving this:
to give your activity's root view a known ID, say '#+id/activityRoot', hook a GlobalLayoutListener into the ViewTreeObserver, and from there calculate the size diff between your activity's view root and the window size:
Customize your top-level layout class into one which overrides onMeasure()
And I would like to credit the above answer to this SO Post: how-to-check-visibility-of-software-keyboard-in-android, which I have found earlier on this particular problem.
I have a viewpager including 3 pages. I set one viewgroup in each page and each of them has 4 items. Now I want to hold and drag one item from this page to another one.I already dealt with draging Item to the corner of the page but when moving to the new page, the new Item is not dragged. Is there any way to handle this problem?
Thanks :)
I haven't implemented drag and drop before so this might not work but perhaps you could make an invisible overlay view like a framelayout on top of the viewpager. Then handle all drag and drop coordination on this view.