Last active
August 29, 2015 14:19
-
-
Save happycodinggirl/a91dcc132fbe3f70fd0d to your computer and use it in GitHub Desktop.
Activity里面嵌入fragment ,带抽屉效果的动画。
This file contains hidden or 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
<?xml version="1.0" encoding="utf-8"?> | |
<set xmlns:android="http://schemas.android.com/apk/res/android"> | |
<translate | |
android:fromXDelta="100%p" | |
android:toXDelta="0%p" | |
android:duration="800" | |
></translate> | |
</set> |
This file contains hidden or 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
package com.lily.huangxingli.testexample; | |
import android.support.v4.app.FragmentTransaction; | |
import android.support.v7.app.ActionBarActivity; | |
import android.os.Bundle; | |
import android.view.View; | |
import android.widget.Button; | |
public class MainActivity extends ActionBarActivity { | |
@Override | |
protected void onCreate(Bundle savedInstanceState) { | |
super.onCreate(savedInstanceState); | |
setContentView(R.layout.activity_main); | |
Button button= (Button) findViewById(R.id.button); | |
button.setOnClickListener(new View.OnClickListener() { | |
@Override | |
public void onClick(View v) { | |
android.support.v4.app.FragmentManager fragmentManager=getSupportFragmentManager(); | |
FragmentTransaction transaction=fragmentManager.beginTransaction(); | |
transaction.setCustomAnimations(R.anim.inanim,R.anim.out); | |
transaction.replace(R.id.framecontainer, new FloatFragment()); | |
transaction.addToBackStack(null); | |
transaction.commit(); | |
} | |
}); | |
} | |
} |
This file contains hidden or 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
<?xml version="1.0" encoding="utf-8"?> | |
<set xmlns:android="http://schemas.android.com/apk/res/android" | |
android:duration="2000"> | |
<translate | |
android:fromXDelta="0%p" | |
android:toXDelta="100%p" | |
android:duration="2000" | |
></translate> | |
</set> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
注意在5.0及以上没有想要的效果,效果不同。