Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Swap android view

Tags:

android

I need to provide facility as shown in images.

enter image description here

Second View

In first view when there is viewpager at bottom. When user swap from right to left the first should replace by second. That I can do. But
My question is how to so half portion of next view at end of right side and and of left side.

i.e.'irst' of first view and 'Thir' of second view.

like image 763
user861973 Avatar asked Aug 14 '12 09:08

user861973


People also ask

How do I change the view on my Android?

You can try to remove the first TextView and then add back to the end of the linear layout using addView. TextView tv = (TextView)layout. getChildAt(0); layout. removeView(tv); layout.

What is Android View View?

View is a basic building block of UI (User Interface) in android. A view is a small rectangular box that responds to user inputs. Eg: EditText, Button, CheckBox, etc. ViewGroup is an invisible container of other views (child views) and other ViewGroup.

What is View tag in Android?

Tags are essentially an extra piece of information that can be associated with a view. They are most often used as a convenience to store data related to views in the views themselves rather than by putting them in a separate structure. Reference: http://developer.android.com/reference/android/view/View.html.


2 Answers

You can use gallery here. Inside gallery for each items, set the layout params (width) to fit with your requirement.

Problem with gallery is that it does not rotate the items. Which means that once you reach the end of the list, you do not get first item.

But there is a trick to over come that too. All you need to do is to set the list count to very large number (INT_MAX) and in your adapter carefully return proper views by % calculation.

This will ensure that you will not reach end of list soon.

like image 95
Chitranshu Asthana Avatar answered Sep 22 '22 05:09

Chitranshu Asthana


I'd suggest checking out the solution for the question Android ViewPager with previous and next pages visible?) - using a negative page margin (via ViewPager.setPageMargin) will allow you see multiple pages at a time (i.e., to the left and right of your current page).

like image 38
ianhanniballake Avatar answered Sep 24 '22 05:09

ianhanniballake