I am using ViewAnimation :
With the help of view Animation , How i can swap the Screen from left to right and right to left like viewPagger . As I know ,we can do it with Touch , but it is not right way , In Touch Mode , when i click on Screen , next screen will be visible , But I need Like ViewPagger .
<!-- This is View Animation Xml code, In which we have two Layout(Screen) one for GridView and WebView and Second Layout Screen for ListView and WebView -->
<ViewAnimator
android:id="@+id/viewSwitcher_ID" <ViewAnimator
android:id="@+id/viewSwitcher_ID"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<LinearLayout
android:id="@+id/linear_wWeb"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<GridView
android:id="@+id/gridview"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:numColumns="auto_fit"
android:verticalSpacing="2dp"
android:horizontalSpacing="2dp"
android:columnWidth="500dp"
android:layout_marginLeft="5dip"
android:layout_marginRight="5dip"
android:layout_marginTop="10dip"
android:layout_marginBottom="5dip"
android:background="@drawable/list_selector"
android:stretchMode="columnWidth"
android:gravity="center" />
<WebView
android:id="@+id/webGrid_ID"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@drawable/webview_div"
android:layout_marginLeft="5dip"
android:layout_marginRight="5dip"
android:visibility="gone" />
</LinearLayout>
<LinearLayout
android:id="@+id/linear_wList"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="horizontal"
android:weightSum="5" >
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="2"
android:orientation="vertical" >
<ListView
android:id="@+id/mylist"
android:layout_width="wrap_content"
android:layout_height="530dp"
android:background="@drawable/list_selector" >
</ListView>
<RelativeLayout
android:id="@+id/gallery_relative_layout"
android:layout_width="fill_parent"
android:layout_height="70dip"
android:layout_gravity="bottom"
android:background="@drawable/headertest"
android:paddingLeft="4dip"
android:paddingRight="4dip"
android:paddingTop="5dip"
android:paddingBottom="5dip"
android:layout_marginBottom="20dip"
android:orientation="horizontal" >
<ImageButton
android:id="@+id/leftArrow"
android:layout_width="40dip"
android:layout_height="50dip"
android:layout_alignParentBottom="true"
android:layout_marginBottom="5dip"
android:background="@drawable/fleft_arrow" />
<HorizontalScrollView
android:id="@+id/horizontal"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="2dip"
android:layout_marginRight="2dip"
android:layout_alignParentBottom="true"
android:layout_toLeftOf="@+id/rightArrow"
android:layout_toRightOf="@+id/leftArrow" >
<LinearLayout
android:id="@+id/linearLayout1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:gravity="center_horizontal|bottom"
android:orientation="horizontal"
android:layout_marginBottom="5dip"
android:layout_alignParentBottom="true" >
<Button
android:id="@+id/button1"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="@drawable/selector1" />
<Button
android:id="@+id/button2"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="@drawable/selector2" />
<Button
android:id="@+id/button3"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="@drawable/selector3" />
<Button
android:id="@+id/button4"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="@drawable/selector4" />
<Button
android:id="@+id/button5"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="@drawable/selector5" />
<Button
android:id="@+id/button6"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="@drawable/selector6" />
<Button
android:id="@+id/button7"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="@drawable/selector7" />
<Button
android:id="@+id/button8"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="@drawable/selector8" />
</LinearLayout>
</HorizontalScrollView>
<ImageButton
android:id="@+id/rightArrow"
android:layout_width="40dip"
android:layout_height="50dip"
android:layout_marginBottom="5dip"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:background="@drawable/fright_arrow"
/>
</RelativeLayout>
</LinearLayout>
<View
android:layout_width="2dp"
android:layout_height="fill_parent"
android:background="@android:color/black" />
<LinearLayout
android:layout_width="0dp"
android:layout_height="fill_parent"
android:layout_weight="3"
android:background="@drawable/webview_div">
<WebView
android:id="@+id/webviewFirstLinear"
android:layout_width="0dp"
android:layout_height="fill_parent"
android:layout_weight="3" />
</LinearLayout>
</LinearLayout>
</ViewAnimator>
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<LinearLayout
android:id="@+id/linear_wWeb"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<GridView
android:id="@+id/gridview"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:numColumns="auto_fit"
android:verticalSpacing="2dp"
android:horizontalSpacing="2dp"
android:columnWidth="500dp"
android:layout_marginLeft="5dip"
android:layout_marginRight="5dip"
android:layout_marginTop="10dip"
android:layout_marginBottom="5dip"
android:background="@drawable/list_selector"
android:stretchMode="columnWidth"
android:gravity="center" />
<WebView
android:id="@+id/webGrid_ID"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@drawable/webview_div"
android:layout_marginLeft="5dip"
android:layout_marginRight="5dip"
android:visibility="gone"
/>
</LinearLayout>
<LinearLayout
android:id="@+id/linear_wList"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="horizontal"
android:weightSum="5" >
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="2"
android:orientation="vertical" >
<ListView
android:id="@+id/mylist"
android:layout_width="wrap_content"
android:layout_height="530dp"
android:background="@drawable/list_selector" >
</ListView>
<RelativeLayout
android:id="@+id/gallery_relative_layout"
android:layout_width="fill_parent"
android:layout_height="70dip"
android:layout_gravity="bottom"
android:background="@drawable/headertest"
android:paddingLeft="4dip"
android:paddingRight="4dip"
android:paddingTop="5dip"
android:paddingBottom="5dip"
android:layout_marginBottom="20dip"
android:orientation="horizontal" >
<ImageButton
android:id="@+id/leftArrow"
android:layout_width="40dip"
android:layout_height="50dip"
android:layout_alignParentBottom="true"
android:layout_marginBottom="5dip"
android:background="@drawable/fleft_arrow" />
<HorizontalScrollView
android:id="@+id/horizontal"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="2dip"
android:layout_marginRight="2dip"
android:layout_alignParentBottom="true"
android:layout_toLeftOf="@+id/rightArrow"
android:layout_toRightOf="@+id/leftArrow" >
<LinearLayout
android:id="@+id/linearLayout1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:gravity="center_horizontal|bottom"
android:orientation="horizontal"
android:layout_marginBottom="5dip"
android:layout_alignParentBottom="true" >
<Button
android:id="@+id/button1"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="@drawable/selector1" />
<Button
android:id="@+id/button2"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="@drawable/selector2" />
<Button
android:id="@+id/button3"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="@drawable/selector3" />
<Button
android:id="@+id/button4"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="@drawable/selector4" />
<Button
android:id="@+id/button5"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="@drawable/selector5" />
<Button
android:id="@+id/button6"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="@drawable/selector6" />
<Button
android:id="@+id/button7"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="@drawable/selector7" />
<Button
android:id="@+id/button8"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="@drawable/selector8" />
</LinearLayout>
</HorizontalScrollView>
<ImageButton
android:id="@+id/rightArrow"
android:layout_width="40dip"
android:layout_height="50dip"
android:layout_marginBottom="5dip"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:background="@drawable/fright_arrow"
/>
</RelativeLayout>
</LinearLayout>
<View
android:layout_width="2dp"
android:layout_height="fill_parent"
android:background="@android:color/black" />
<LinearLayout
android:layout_width="0dp"
android:layout_height="fill_parent"
android:layout_weight="3"
android:background="@drawable/webview_div">
<WebView
android:id="@+id/webviewFirstLinear"
android:layout_width="0dp"
android:layout_height="fill_parent"
android:layout_weight="3" />
</LinearLayout>
</LinearLayout>
</ViewAnimator>
How i can get this approach with the help of ViewAnimation or Gesture with left scrolling or Right scrolling.| There is any way to flip the screen as animation left in and animation right in using translation,scale , rotation etc
如果你愿意在你的项目中使用库..它可以帮助你https://github.com/JakeWharton/Android-ViewPagerIndicator
The following links may help you to achieve your requirement. It is same like your screenshots that you attached(Google Play like home screen).
for left_in.xml
<set xmlns:android="http://schemas.android.com/apk/res/android">
<!-- Before rotating, immediately set the alpha to 0. -->
<objectAnimator
android:valueFrom="1.0"
android:valueTo="0.0"
android:propertyName="alpha"
android:duration="0" />
<!-- Rotate. -->
<objectAnimator
android:valueFrom="-180"
android:valueTo="0"
android:propertyName="rotationY"
android:interpolator="@android:interpolator/accelerate_decelerate"
android:duration="@integer/card_flip_time_full" />
<!-- Half-way through the rotation (see startOffset), set the alpha to 1. -->
<objectAnimator
android:valueFrom="0.0"
android:valueTo="1.0"
android:propertyName="alpha"
android:startOffset="@integer/card_flip_time_half"
android:duration="1" />
</set>
for left_out.xml
<set xmlns:android="http://schemas.android.com/apk/res/android">
<!-- Rotate. -->
<objectAnimator
android:valueFrom="0"
android:valueTo="-180"
android:propertyName="rotationY"
android:interpolator="@android:interpolator/accelerate_decelerate"
android:duration="@integer/card_flip_time_full" />
<!-- Half-way through the rotation (see startOffset), set the alpha to 0. -->
<objectAnimator
android:valueFrom="1.0"
android:valueTo="0.0"
android:propertyName="alpha"
android:startOffset="@integer/card_flip_time_half"
android:duration="1" />
</set>
you need to create both of animation xml file under /res/animator folder. Using follow code to apply the animation to View or Activity
Intent i = new Intent(first.this, second.class);
startActivity(i);
overridePendingTransition(R.animator.push_left_in,R.animator.push_left_out);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.