This repository has been archived by the owner on Apr 19, 2018. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Properly honor pivot for scale operation.
Add ViewHelper class which will correctly set the pivot in the appropriate place depending on the current API level.
- Loading branch information
1 parent
399abe8
commit 3cb6d1d
Showing
4 changed files
with
142 additions
and
72 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package com.nineoldandroids.view; | ||
|
||
import android.view.View; | ||
|
||
import static com.nineoldandroids.view.animation.AnimatorProxy.NEEDS_PROXY; | ||
import static com.nineoldandroids.view.animation.AnimatorProxy.wrap; | ||
|
||
public final class ViewHelper { | ||
private ViewHelper() {} | ||
|
||
public static void setPivotX(View view, float pivotX) { | ||
if (NEEDS_PROXY) { | ||
wrap(view).setPivotX(pivotX); | ||
} else { | ||
SetPivotX.invoke(view, pivotX); | ||
} | ||
} | ||
|
||
public static void setPivotY(View view, float pivotY) { | ||
if (NEEDS_PROXY) { | ||
wrap(view).setPivotY(pivotY); | ||
} else { | ||
SetPivotY.invoke(view, pivotY); | ||
} | ||
} | ||
|
||
private static final class SetPivotX { | ||
static void invoke(View view, float pivotX) { | ||
view.setPivotX(pivotX); | ||
} | ||
} | ||
|
||
private static final class SetPivotY { | ||
static void invoke(View view, float pivotY) { | ||
view.setPivotY(pivotY); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,75 +1,94 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
|
||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" | ||
android:layout_width="fill_parent" | ||
android:layout_height="fill_parent" | ||
android:orientation="vertical"> | ||
android:layout_width="fill_parent" | ||
android:layout_height="fill_parent" | ||
android:orientation="vertical"> | ||
<LinearLayout | ||
android:orientation="horizontal" | ||
android:layout_width="fill_parent" | ||
android:layout_height="wrap_content"> | ||
android:orientation="horizontal" | ||
android:layout_width="fill_parent" | ||
android:layout_height="wrap_content"> | ||
<Button | ||
android:id="@+id/tx" | ||
android:layout_width="0dp" | ||
android:layout_height="wrap_content" | ||
android:layout_weight="1" | ||
android:text="TX"/> | ||
android:id="@+id/tx" | ||
android:layout_width="0dp" | ||
android:layout_height="wrap_content" | ||
android:layout_weight="1" | ||
android:text="TX"/> | ||
<Button | ||
android:id="@+id/ty" | ||
android:layout_width="0dp" | ||
android:layout_height="wrap_content" | ||
android:layout_weight="1" | ||
android:text="TY"/> | ||
android:id="@+id/ty" | ||
android:layout_width="0dp" | ||
android:layout_height="wrap_content" | ||
android:layout_weight="1" | ||
android:text="TY"/> | ||
<Button | ||
android:id="@+id/sx" | ||
android:layout_width="0dp" | ||
android:layout_height="wrap_content" | ||
android:layout_weight="1" | ||
android:text="SX"/> | ||
android:id="@+id/sx" | ||
android:layout_width="0dp" | ||
android:layout_height="wrap_content" | ||
android:layout_weight="1" | ||
android:text="SX"/> | ||
<Button | ||
android:id="@+id/sy" | ||
android:layout_width="0dp" | ||
android:layout_height="wrap_content" | ||
android:layout_weight="1" | ||
android:text="SY"/> | ||
android:id="@+id/sy" | ||
android:layout_width="0dp" | ||
android:layout_height="wrap_content" | ||
android:layout_weight="1" | ||
android:text="SY"/> | ||
</LinearLayout> | ||
<LinearLayout | ||
android:orientation="horizontal" | ||
android:layout_width="fill_parent" | ||
android:layout_height="wrap_content"> | ||
android:orientation="horizontal" | ||
android:layout_width="fill_parent" | ||
android:layout_height="wrap_content"> | ||
<Button | ||
android:id="@+id/a" | ||
android:layout_width="0dp" | ||
android:layout_height="wrap_content" | ||
android:layout_weight="1" | ||
android:text="Alpha"/> | ||
android:id="@+id/a" | ||
android:layout_width="0dp" | ||
android:layout_height="wrap_content" | ||
android:layout_weight="1" | ||
android:text="Alpha"/> | ||
<Button | ||
android:id="@+id/rx" | ||
android:layout_width="0dp" | ||
android:layout_height="wrap_content" | ||
android:layout_weight="1" | ||
android:text="RX"/> | ||
android:id="@+id/rx" | ||
android:layout_width="0dp" | ||
android:layout_height="wrap_content" | ||
android:layout_weight="1" | ||
android:text="RX"/> | ||
<Button | ||
android:id="@+id/ry" | ||
android:layout_width="0dp" | ||
android:layout_height="wrap_content" | ||
android:layout_weight="1" | ||
android:text="RY"/> | ||
android:id="@+id/ry" | ||
android:layout_width="0dp" | ||
android:layout_height="wrap_content" | ||
android:layout_weight="1" | ||
android:text="RY"/> | ||
<Button | ||
android:id="@+id/rz" | ||
android:layout_width="0dp" | ||
android:id="@+id/rz" | ||
android:layout_width="0dp" | ||
android:layout_height="wrap_content" | ||
android:layout_weight="1" | ||
android:text="RZ"/> | ||
</LinearLayout> | ||
<LinearLayout | ||
android:layout_height="wrap_content" | ||
android:layout_weight="1" | ||
android:text="RZ"/> | ||
android:layout_width="fill_parent" | ||
android:orientation="horizontal"> | ||
<Button | ||
android:id="@+id/pivot_corner" | ||
android:layout_height="wrap_content" | ||
android:layout_width="0dp" | ||
android:layout_weight="1" | ||
android:text="Pivot Corner"/> | ||
<Button | ||
android:id="@+id/pivot_center" | ||
android:layout_height="wrap_content" | ||
android:layout_width="0dp" | ||
android:layout_weight="1" | ||
android:text="Pivot Center"/> | ||
</LinearLayout> | ||
<LinearLayout | ||
android:layout_height="fill_parent" | ||
android:layout_width="fill_parent" | ||
android:gravity="center"> | ||
<FrameLayout | ||
android:id="@+id/target" | ||
android:layout_width="100dp" | ||
android:layout_height="100dp" | ||
android:background="#FFFF0000"/> | ||
android:layout_height="0dp" | ||
android:layout_width="fill_parent" | ||
android:layout_weight="1" | ||
android:gravity="center"> | ||
<Button | ||
android:id="@+id/target" | ||
android:layout_width="100dp" | ||
android:layout_height="100dp" | ||
android:text="Sample Text" | ||
android:gravity="center"/> | ||
</LinearLayout> | ||
</LinearLayout> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters