2

I am attaching image to explain my question in more detail. Also attaching android manifest.

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="XXXXXXXXXX"
android:versionCode="1"
android:versionName="1.0" >

<uses-sdk android:targetSdkVersion="15" android:minSdkVersion="8"/>

<application
    android:icon="@drawable/ic_launcher"
    android:label="@string/app_name" 
    android:hardwareAccelerated="true">        
    <activity
        android:label="@string/app_name"
        android:name="TabsMainActivity"

<!-- If I remove the line below I get normal 
ICS action bar instead of title bar u see in below image -->

        android:theme="@style/Theme.PageIndicatorDefaults">  

        <intent-filter >
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
</application>
</manifest>

Also if you see the edit text and spinner UI , its like one that we see on android versions below ICS. And Screenshot is from my phone running ICS 4.0.4. prob with title in VPI

Rohit
  • 2,538
  • 6
  • 28
  • 41
  • Try adding: 'true' to your style declaration in the 'styles.xml' – Siddharth Lele May 11 '12 at 09:42
  • I know I can solve title prob by using requestWindowFeature() method from code also, but the prob is the whole UI is not in ICS format – Rohit May 11 '12 at 09:49
  • What do you mean "the whole UI is not in ICS format"? You mean its a combination of sorts? I didn't quite understand that part. – Siddharth Lele May 11 '12 at 09:50
  • look at edit text, spinner next to contact, also buttons at bottom.. They are not looking like one we see on android 4. They look like one we see in old versions of android.. And if you see the app is targeted to api level 15. So, they should look like one we see in android 4 on android 4 phones and look like old android when the application running on phones with other android version – Rohit May 11 '12 at 09:53
  • But isn't that expected when you use a custom style? Remove the custom style declaration in your manifest and try it on different android versions. Then you will get the default look. – Siddharth Lele May 11 '12 at 09:55
  • The tabs you see in screenshot needs the style to be declared in activity manifest, you should know this if you have used ViewPageIndicator of Jake Wharton – Rohit May 11 '12 at 09:57
  • https://github.com/JakeWharton/Android-ViewPagerIndicator/blob/master/sample/AndroidManifest.xml see this manifest and you ll come to know what I am talking.. And if I remove that line from manifest I get distorted tabs. – Rohit May 11 '12 at 09:58
  • Sure. I get your point. But that really brings me back to my earlier comment. Which you also acknowledge. Removing that line sets everything right (minus the tabs of course) as it goes back to defaults for each platform. I suppose, it is a pit fall of using styled themes. – Siddharth Lele May 11 '12 at 10:07
  • A quick question. Where is the "PageIndicatorDefaults" theme declared in the styles.xml? I did not see it in his github sample. And if there isn't a parent set for the style in your copy, perhaps you can try setting, for example, "parent="@android:style/Theme.Light" after the style name tag. – Siddharth Lele May 11 '12 at 10:07
  • I got the problems' solution .. will posting it in answer.. but the bad news is I need to change some code in library – Rohit May 11 '12 at 10:25
  • Well, as long as it works... ;-) Looking forward to the answer. – Siddharth Lele May 11 '12 at 10:26

1 Answers1

2

I solved the problem by editing vpi__styles.xml from ViewPagerIndicator. The code before I edited was : -

<style name="Theme.PageIndicatorDefaults" parent="android.Theme">
    <item name="vpiCirclePageIndicatorStyle">@style/Widget.CirclePageIndicator</item>
    <item name="vpiTitlePageIndicatorStyle">@style/Widget.TitlePageIndicator</item>
    <item name="vpiTabPageIndicatorStyle">@style/Widget.TabPageIndicator</item>
    <item name="vpiTabTextStyle">@style/Widget.TabPageIndicator.Text</item>
</style>

The code after I edited file is :-

<style name="Theme"></style>  <!-- I declared new style which dont have parent with android.Theme -->
<style name="Theme.PageIndicatorDefaults" parent="Theme">  <!-- Extended this style from style I declared above -->
    <item name="vpiCirclePageIndicatorStyle">@style/Widget.CirclePageIndicator</item>
    <item name="vpiTitlePageIndicatorStyle">@style/Widget.TitlePageIndicator</item>
    <item name="vpiTabPageIndicatorStyle">@style/Widget.TabPageIndicator</item>
    <item name="vpiTabTextStyle">@style/Widget.TabPageIndicator.Text</item>
</style>

This solved the problem and shows action bar instead of title bar on android 4 devices and normal title bar on android 2.1- 2.3.x devices.

Rohit
  • 2,538
  • 6
  • 28
  • 41