根据https://developer.android.com/training/material/animations.html
通过该
ViewAnimationUtils.createCircularReveal()方法,您可以设置剪贴圆的动画以显示或隐藏视图.要使用此效果显示以前不可见的视图:
Run Code Online (Sandbox Code Playgroud)// previously invisible view View myView = findViewById(R.id.my_view); // get the center for the clipping circle int cx = (myView.getLeft() + myView.getRight()) / 2; int cy = (myView.getTop() + myView.getBottom()) / 2; // get the final radius for the clipping circle int finalRadius = Math.max(myView.getWidth(), myView.getHeight()); // create the animator for this view (the start radius is zero) Animator anim = ViewAnimationUtils.createCircularReveal(myView, cx, cy, 0, finalRadius); // make the view visible and start the …
所以最近我试图实现一个 FAB,它将扩展到一个新的活动,但在按下 FAB 后它崩溃了。此外,从这个问题,我遵循了实现它的步骤:FloatingActionButton expand into a new Activity
日志猫:
Process: com.example.jovie.canteen, PID: 6953
java.lang.NullPointerException: Attempt to invoke virtual method 'void android.view.View.setVisibility(int)' on a null object reference
at com.example.jovie.canteen.Home$1$2.run(Home.java:105)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5417)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
Run Code Online (Sandbox Code Playgroud)
主页.java
public class Home extends AppCompatActivity
implements NavigationView.OnNavigationItemSelectedListener {
CoordinatorLayout homeLayout;
private GoogleApiClient client;
private Toolbar toolbar;
private TabLayout tabLayout;
private ViewPager viewPager;
private RevealLayout mRevealLayout;
View mViewToReveal;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); …Run Code Online (Sandbox Code Playgroud)