Scroll view to left in android app - android

in my app i have place a text view in the middle of the layout and when i scroll screen to left i want to show the google maps. So far i am showing the google aps by ontouch method.
how to perform this...

You can use a third party called SwipeView.
It's an extension of the HorizontalScrollView class.

USE THIS , its working fine and no delays
hor = (HorizontalScrollView) findViewById(R.id.horizontalScrollView1);
hor.postDelayed(new Runnable() {
public void run() {
hor.fullScroll(HorizontalScrollView.FOCUS_RIGHT);
}
}, 1L);

Related

Android partially active Activity

I have an activity A. I am creating a kind of tutorial for user for this activity, to teach him how he can use the app on that screen.
For that, my requirement is :
I want to blur all the views of the activity except one view. I want to prompt user to click on that view through a hand image pointing at that view.
Nothing should happen if the user clicks on the blurred/greyed out area, but if he taps on that particular active view, it should react to that touch.
I was thinking of using a full screen fragment for this. The Fragment will take the following input from the activity :
for what coordinates, is should not blur the screen and pass the touch event to the activity
the coordinates on which it should show that pointing hand image.
After from these coordinates, the fragment background would be blur.
I wanted to confirm if that's possible, to make the fragment partially active, i.e. delegate it's touch events to the activity for a particular view of the activity.
Also, please let me know if there is any other better approach of achieving the same thing.
Edit1 :
Thinking of using a fragment here, because I'd want this type of behaviour on different screen in future. In that case, I'd make that fragment generic which takes some inputs (as described above) and use it on different screens.
There's a very good library called SCV which does what you're trying to achieve, you're able to customize the styles for it too. I've used this for first time the app is opened to show the user a tutorial.
According to their Github
The ShowcaseView (SCV) library is designed to highlight and showcase specific parts of apps to the user with a distinctive and attractive overlay. This library is great for pointing out points of interest for users, gestures, or obscure but useful items.
Further Reading:
Android Arsenal - Showcase Views Tutorial
ShowCaseView on Android - Indipendev
I found it much easier to include an 'extra' layout around the UI of my activity, and then to add a highest-z grey mostly-transparent filter to it and put the instructions on that.
Each "step" of the instructions was a different layout that was dynamically loaded into that layout container as they clicked. (Just another approach)
The 'container' layout is a: FrameLayout
then in my Activity I have: (ignore bad naming)
private void addOverlayLayout() {
frameLayout = (FrameLayout) findViewById(R.id.framelayoutInner);
frameLayout3 = (FrameLayout) findViewById(R.id.framelayout3);
frameLayout3.setBackgroundColor(Color.DKGRAY);
frameLayout3.setAlpha(0.3f);
// Dynamically create a relativelayout which will be appended to framelayout
relativeLayout = new RelativeLayout(getApplicationContext());
relativeLayout.setLayoutParams(new RelativeLayout.LayoutParams(ViewGroup.LayoutParams
.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
instructionOverlays.add(createSimpleClickInstruction(R.layout.instruction_reader_1));
instructionOverlays.add(createSimpleClickInstruction(R.layout.instruction_reader_2));
if (FullscreenReaderActivity.isFirstRun) {
displayNextGuide();
}
}
public void displayNextGuide() {
// clean relative layout if it has views
relativeLayout.removeAllViews();
// clean frame layout if it has child (safe if empty)
frameLayout.removeView(relativeLayout);
if (!isFirstRun) {
return;
}
if (instructionOverlays.size() > 0) {
runOnUiThread(instructionOverlays.get(0));
instructionOverlays.remove(0);
} else {
frameLayout3.setBackgroundColor(Color.TRANSPARENT);
frameLayout3.setAlpha(1.0f);
}
}
public Runnable createSimpleClickInstruction(final int resource) {
return new Runnable() {
#Override
public void run() {
getLayoutInflater().inflate(
resource,
relativeLayout,
true
);
relativeLayout.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
displayNextGuide();
}
});
frameLayout.addView(relativeLayout);
}
};
}

Scroll down to load data using recycleview and SwipeRefreshLayout

We've been looking around for the implementation of the new material design swipe down to refresh on RecyclerViews with the loading circle coming down from bottom view same like new gmail app.i found so many things. But not getting new gmail app like example or demo .i already implement refreshlayout and recycleview.
But when scroll down to recycleview,how to put loading circle at the last of the record in recycleview. I want to get some idea to put in onscroll of recycleview.
recyclerView.setOnScrollListener(new RecyclerView.OnScrollListener() {
#Override
public void onScrollStateChanged(int arg0) {
}
#Override
public void onScrolled(int arg0, int arg1) {
//add some data but not to show loader.
getDataFromDB();
}
});
hi If you wan't to develop such a kind of Layout then please follow this url, i was used it it's an awesome.
https://github.com/stormzhang/SwipeRefreshLayoutDemo
You should wrap all your layouts with
pull to refresh component for that.
after swipeRefreshLayout.setOnRefreshListener and set swipeRefreshLayout.setRefreshing(true); when you send API call
hear is awesome demo for both Scroll down to load data using recycleview and Swipe to RefreshLayout.

Scrolling webview credit text in android

I need to make a credits screen in my application. It would be vertically scrolling lines. It is html page with images so I can only use webview. Scrolling is to be performed automatically and no user interaction is allowed. Just like movie/serials credits that goes from bottom to top. I have html page added in assets folder.
How to implement this animation?
Since you are using a webview, you can actually use jQuery to accomplish this.
$('a[href=#bottom]').click(function(){
$('html, body').animate({scrollTop:0}, 'slow');
});
Slow down scroll to top event by jQuery animate
Or you could use a handler
private Runnable mScrollDown = new Runnable()
{
public void run()
{
WebView webview = (WebView)findViewById(R.id.web_url);
webview.scrollBy(0, scrollSpeed);
mHandler.postDelayed(this, 200);
}
};

Adjusting the scrollview at the bottom of the page

I have lots of contents on one page so i am using scrollview. I have one scan button at the bottom of the page, which i need to click many times to scan lots of barcodes. when i click on scan button, i am opening "BarcodeScanner" application that will sacn the barcode and returns the result to my application. so when i come back to my application, again i need to scroll the entire page to click the scan button which is at the bottom side. So is there any way to initialize the scroll at the bottom of the page? Please help
Thanks in advance
How do you think that you can initialise the scroll view.!! If you have lots of contents in a page you have to use scroll view for seeing all the contents. ! Try this, put your scroll view xml code in to botom of the xml code. and check.!!
Say your ScrollView id is scrollId, the code will lokk like this
scrollView = (ScrollView) findViewById (R.id.scrollId);
scrollView.post(new Runnable() {
#Override
public void run() {
scrollView.fullScroll(View.FOCUS_DOWN);
}
});
Try this
s.post(new Runnable() {
public void run() {
s.scrollTo(0, mScrollView.getBottom());
// or this
//s.fullScroll(s.FOCUS_DOWN);
}
});

Android gallery auto scroll with threshold values

I have created a custom gallery in which I have implemented the drag and drop mechanism and rearranged the items.Drag happens during a long click event and fling also works fine.Now my problem is I am trying to auto scroll my gallery during a drag operation when a particular threshold value is reached on the left and side of the gallery,for this i tried using scrollto, setselection both of them seems to be working weird,can somebody help me out with this issue.
Instead of :
myGallery.setSelection(position);
Try :
myGallery.post(new Runnable() {
#Override
public void run() {
myGallery.setSelection(position);
}
});
The same thing with scrollTo should also work.
I hope it will help you.

Categories

Resources