简体   繁体   English

PagerTitleStrip不会在第一个显示页面上显示标题,标题仅在刷到另一个页面后绘制

[英]PagerTitleStrip do not show titles on first display page, the titles are only drawn after swiping to another page

Issue: After updating to appcompat-v7:23.0.0, both PagerTabStrip and PagerTitleStrip do not show titles on first display page (fig1), the titles are only drawn after swiping to another page (fig2). 问题:更新到appcompat-v7:23.0.0后,PagerTabStrip和PagerTitleStrip都没有在第一个显示页面上显示标题(图1),标题仅在刷到另一个页面后绘制(图2)。

Library used : appcompat-v7 使用的库:appcompat-v7

Version used: 23.0.0 使用的版本:23.0.0

Theme used: Theme.AppCompat.Light.DarkActionBar,Theme.AppCompat.Light.NoActionBar 使用的主题:Theme.AppCompat.Light.DarkActionBar,Theme.AppCompat.Light.NoActionBar

Devices/Android versions reproduced on: Nexus 5/ Android M Developer Preview 2 设备/ Android版本转载于:Nexus 5 / Android M开发者预览版2

Steps to reproduce: 重现步骤:

    1. Create a new sample project, minSdk version doesn't matter. 创建一个新的示例项目,minSdk版本并不重要。
    1. Choose tabbed activity when asked to add an activity. 当系统要求您添加活动时,请选择选项卡式活动。
    1. Add a PagerTabStrip layout inside activity_main.xml such as below: 在activity_main.xml中添加PagerTabStrip布局,如下所示:

     <android.support.v4.view.PagerTabStrip android:id="@+id/title_strip" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_gravity="top" android:paddingBottom="4dp" android:paddingTop="4dp" android:textColor="@android:color/background_dark" /> 

    1. Run the app 运行应用程序

What to expect: titles on the viewpager tab strip should be visible What happened : The titles are not drawn (fig1) unless swiped to another page (fig2) 会发生什么:viewpager标签条上的标题应该是可见的事情发生了:除非刷到另一页(图2),否则不会绘制标题(图1)

Here the link of the issue ... 这里是问题的链接......

https://code.google.com/p/android/issues/detail?id=183127 https://code.google.com/p/android/issues/detail?id=183127

I was having the same problem. 我遇到了同样的问题。 This has been fixed in version 23.1.0. 这已在版本23.1.0中修复。 Update the library, clean the project and it should work. 更新库,清理项目,它应该工作。

try this.. 尝试这个..

protected override void OnLayout (bool changed, int lValue, int tValue, int rValue, int bValue)
{
    for (int i = 0; i < ChildCount; i++) {
        if (GetChildAt (i).GetType () == typeof(TextView)) {
            ((TextView)GetChildAt (i)).Measure (MeasuredWidth, MeasuredHeight);
        }
    }
    base.OnLayout (changed, lValue, tValue, rValue, bValue);
}

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

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