Android disable Sliding Panel Layout on specific condition - android

I am using AndroidSlidingUpPanel on my project . I want to disable sliding on specific condition . So that only top part is visible , and dragging is disabled .

if(condition){
mSlidingLayout.setEnabled(false);
mSlidingLayout.setClickable(false);
}
if the above code doesn't work then try like
if(condition){
runOnUiThread(new Runnable() {
#Override
public void run() {
mSlidingLayout.setEnabled(false);
mSlidingLayout.setClickable(false);
}
});
}

You can use
mDrawerLayout.setDrawerLockMode(DrawerLayout.LOCK_MODE_LOCKED_CLOSED);
to lock your DrawerLayout so it won't be able to open with gestures. And unlock it with:
mDrawerLayout.setDrawerLockMode(DrawerLayout.LOCK_MODE_UNLOCKED);

Related

Android showcase focus tablayout

I'm using FancyShowCaseView library. When focusing on a button it work fine, but when focusing on TabLayout or MenuItem of Android SlidingTabs it don't work.
I'm tring to focus on TabLayout or MenuItem's of my app.
listen i have the same problem and add this:
view.getViewTreeObserver().addOnGlobalLayoutListener(
new ViewTreeObserver.OnGlobalLayoutListener() {
#Override
public void onGlobalLayout() {
// Layout has happened here.
// Don't forget to remove your listener when you are done with it.
view.getViewTreeObserver().removeOnGlobalLayoutListener(this);
}
});
to my code and work fine.

FAB transparent layer does not block the parent layer

I have a problem using Clans FloatingActionButton. I need to add a transparent layer that blocks the parent layer. The effect that I need is similar to Google Inbox.
So in my example I have this sequence:
1) Click item 3
2) Click on fab
3) When I click over transparent layer, the item from ListView is clicked.
I try to block the click event transparent layer using:
final FloatingActionMenu menu1 = (FloatingActionMenu) findViewById(R.id.menu1);
menu1.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
menu1.close(true);
}
});
So with this code, when I click transparent layer the fab menu is closed (this is ok), but the same click listener blocking the click event over listView.
I have tried different ways to solve this problem but the only way I found was to resize the background programmatically . This is not a good solution because the effect is not good.
In a few hours I'll upload a demo and source code to github , but even as hope someone can help me with some idea. Thank You
EDITED
Here is the LINK to my repo.
Here is the LINK to download this apk
Here is the LINK to video demo
I have download your project from Github and tried the code myself and have solved the issue.
It is working perfectly for me as demonstrated in the Inbox by Google app. You just need to change a very small portion of your code.
menu1.setOnMenuToggleListener(new FloatingActionMenu.OnMenuToggleListener() {
#Override
public void onMenuToggle(boolean opened) {
if (opened) {
menu1.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
menu1.close(true);
menu1.setClickable(false);
}
});
} else {
Toast.makeText(getApplicationContext(), "Close", Toast.LENGTH_SHORT).show();
}
}
});
Hope I could help you.

Android scroll up

I have two buttons Button 1, Button 2 placed horizontally like tabs. On Click of these button I am adding Linear Layout in Scroll View.
Now suppose I am clicking Button 1 and scroll down and immediately switch or click to Button 2 that scroll applies on newly added layout. I want every time on click of button content should scroll to top.
I have tried scrollview.scrollT0(0,0) and scrollview.scrollTo(0,scrollview.getTop()) but none of them is working.
I've ran into these types of issues before.
I suggest trying the following:
scrollview.post(new Runnable() {
#Override
public void run() {
scrollview.scrollTo(0, 0);
}
});
The reason this works is forces the action in the Main Thread which is where all UI Activity happens (safely, of course).
Try this . Just it is sample
private void scrollMyListViewToBottom() {
your_list.post(new Runnable() {
public void run() {
if (!running) {
// Select the last row so it will scroll into view...
your_list.setSelection(your_list.getCount() - 1);
running = true;
}
}
});
Note :
Before call this method just change Boolean running = false;

How to make Scroll Bar set to bottom on Click?

Hi I want to make Scroll Bar set to Bottom to my Activity on Button Click.
I have try using
final ScrollView Scrbar=(ScrollView)findViewById(R.id.ScrollContainer);
Scrbar.post(new Runnable() {
#Override
public void run(){
Scrbar.fullScroll(ScrollView.FOCUS_DOWN);
}
});
But It's not working the way I want.
How should I'll meet to my requirements?
please suggest
Try
scrollView.post(new Runnable() {
public void run() {
scrollView.scrollTo(0, scrollView.getBottom());
}
});
Try to use this: Scrbar.scrollTo(0, Scrbar.getBottom());

how to scroll horizontal scroll view without animation

The problem is that I'm using the fullScroll() and scrollTo() functions to scroll but it is animated and I need it happen without user observation.
Is there a way to solve this problem?
hScrollView.post(new Runnable() {
#Override
public void run() {
hScrollView.fullScroll(HorizontalScrollView.FOCUS_RIGHT);
}
});
Use this
// Disable the animation First
hScrollView.setSmoothScrollingEnabled(false);
// Now scroll the view
hScrollView.fullScroll(HorizontalScrollView.FOCUS_RIGHT);
// Now enable the animation again if needed
hScrollView.setSmoothScrollingEnabled(true);
You can use hScrollView.setSmoothScrollingEnabled(false); before running the Runnable command, this will give you the desired output
// Set smooth scrolling to false
hScrollView.setSmoothScrollingEnabled(false);
// Then call the fullScroll method
hScrollView.post(new Runnable() {
#Override
public void run() {
hScrollView.fullScroll(View.FOCUS_RIGHT);
}
});

Categories

Resources