简体   繁体   English

在没有闪光灯的情况下切换活动

[英]Switching between activities with no flash

I've searched long and hard for an answer to this question but can't find any answers. 我已经花了很长时间寻找这个问题的答案,但是找不到任何答案。 My problem is that I created an XML file with 5 buttons on it and each button is linked to another xml file. 我的问题是我创建了一个XML文件,上面有5个按钮,每个按钮都链接到另一个xml文件。 Once clicked, the button takes you to the next xml file with the same 5 buttons in the same location. 单击后,该按钮会将您带到下一个xml文件,该文件在相同位置具有相同的5个按钮。 The problem I face is that when the pages are switching, there is an ever so slight flash of black. 我面临的问题是,在切换页面时,会出现非常轻微的黑色闪烁。 Then there's a second where the toolbar loads. 然后是工具栏加载的第二个位置。 How do I fix this annoying lag and make it fluid? 我该如何解决这个烦人的滞后并使其流畅?

Instead of switching between activities you can simply change between the layout xml files. 无需在活动之间进行切换,您只需在布局xml文件之间进行切换即可。

xml layout1 xml layout1

<Button
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="New Button"
    android:id="@+id/button"
    android:layout_centerVertical="true"
    android:layout_centerHorizontal="true"
    android:onClick="newLayout"/>

java code Java代码

 public void newLayout(View view) {
    setContentView(R.layout.new_layout);

}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM