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. Once clicked, the button takes you to the next xml file with the same 5 buttons in the same location. 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 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
public void newLayout(View view) {
setContentView(R.layout.new_layout);
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.