Android 용 애니메이션을 처음 사용하며 부동산 애니메이션을 사용하려고합니다. x 속성을 변환하여 미끄럼 효과를 얻으려고합니다. 하지만 나는 원하는 결과를 얻지 못하고있다. 레이아웃에 따르면Android : 번역 애니메이션이 올바르게 작동하지 않습니다.
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal" >
<LinearLayout
android:id="@+id/parent"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:orientation="horizontal" >
<LinearLayout
android:id="@+id/first"
android:layout_width="320dp"
android:layout_height="200dp"
android:background="#00ff00" >
</LinearLayout>
<LinearLayout
android:id="@+id/second"
android:layout_width="320dp"
android:layout_height="200dp"
android:background="#0000ff" >
</LinearLayout>
</LinearLayout>
</LinearLayout>
:
내가있는 레이아웃을 가지고있다. 나는 horizanlty 배치 부모 선형 레이아웃에 두 선형 레이아웃이 있습니다. 첫 번째 레이아웃 만 표시되고 두 번째 레이아웃은 화면 밖입니다. 부모 x 속성에 애니메이션을 적용하려고하면 번역을 사용하여 부모를 슬라이드하고 먼저 숨기고 두 번째를 표시합니다. 다음은 내 코드입니다.
그리고 단지 옵션 메뉴를 사용하고있는 애니메이션을 시뮬레이트합니다. 나는 응용 프로그램을 시작하고 때
static boolean a = true;
@Override
public boolean onOptionsItemSelected(MenuItem item) {
if(a){
ObjectAnimator animate = ObjectAnimator.ofFloat(parent_, "x", -parent_.getWidth());
animate.setDuration(500);
animate.start();
animate.addListener(this);
animate.addUpdateListener(this);
a = false;
} else {
ObjectAnimator animate = ObjectAnimator.ofFloat(parent_, "x", -parent_.getWidth(), 0);
animate.setDuration(500);
animate.start();
a = true;
}
return super.onOptionsItemSelected(item);
}
내 응용 프로그램은 다음과 같습니다
및 애니메이션 후 응용 프로그램은 다음과 같습니다
참고 : 흰색을 영역은 실제로 스크린 샷의 일부입니다. 흰색 배경입니다.
애니메이션 후 파란색 레이아웃을 표시하는 대신. 완전히 왼쪽으로 밀고 숨 깁니다. 파란색 레이아웃을 표시하지 않습니다. 애니메이션 도중 스크린 샷을 찍으려고했습니다. 그것은 다음과 같습니다 : 내가 잘못
을 뭐하는 거지 ??? 나는 내 질문을 잘 설명했으면 좋겠다. ...
제 경우에는'clipChildren = "false"'를 설정하는 것이 좋습니다. – findall