简体   繁体   English

标签下划线返回屏幕旋转时的第一个标签

[英]Tab underline returning to the first tab on screen rotation

I haven't used tabs in my project because of some UI constraint, instead I have used three buttons with viewpager which work as a tab. 由于某些UI限制,我没有在项目中使用标签页,而是使用了带有viewpager的三个按钮作为标签页。 Below the three buttons I have used three views which are working as tabs underline. 在这三个按钮下面,我使用了三个视图,这些视图用作选项卡下划线。

The problem is, when the screen is rotated, correct viewpager is showing up, but underline is coming below the first button, however, it should be below the currently selected button. 问题是,旋转屏幕时,将显示正确的viewpager,但下划线位于第一个按钮的下方,但是下划线应位于当前所选按钮的下方。

您必须使用onRestoreInstanceState将视图位置编号(例如选项卡编号2或选项卡编号3)存储在一个包中,并从onSaveInstanceState中读取它。

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

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