2016-07-17 7 views

答えて

0

使用あなたの活動のレイアウトのために、このような何か:

<FrameLayout 
    android:layout_width="match_parent" 
    android:layout_height="match_parent"> 

    <FrameLayout 
     android:layout_width="match_parent" 
     android:layout_height="0dp" 
     android:layout_weight="1"> 

     <Button 
      android:layout_gravity="center" 
      android:layout_width="100dp" 
      android:layout_height="100dp" 
      android:onClick="openFragment"/> 
    </FrameLayout> 

    <FrameLayout 
     android:id="@+id/container" 
     android:layout_width="match_parent" 
     android:layout_height="0dp" 
     android:layout_weight="1"/> 
</FrameLayout> 

その後、あなたの活動で:

public void openFragment(View v) { 
    Fragment fragment = new YourFragment(); 
    fragment.setEnterTransition(android.R.transition.slide_bottom); 
    getSupportFragmentManager().beginTransaction() 
     .add(R.id.container, fragment) 
     .commit(); 
} 

注:

APIのみのための作品

> = 21.

古いバージョンをサポートしたい場合は、FragmentTransaction.setCustomAnimations()を使用する必要があります。

0

ビューのアニメーション作成には、クラスObjectAnimatorを使用できます。プロパティtranslationYのメソッドofFloatを使用すると、目的の効果を得ることができます。 API> = 11が必要です。

関連する問題