Search code examples
androiddialogactionbarsherlock

Button displaying differences on GB and ICS - not visible buttons on ICS with ABS


I solved many problems with stack overflow. I faced specific problem, so it is time to ask you in direct way for the first time.

I use ActionBarSherlock. I wanted for my app to look the same on any device. I need Dialogs, so I decided to use Dialog Theme from ABS. So I've created an activity for my Custom Dialog and I styled it to look like Holo even on earlier Android versions.

That's how does it look on Android 2.3.3 emulator:

https://dl.dropbox.com/u/49293039/problem2.jpg (sorry, I cannot post it as a image due to lacks of my reputation...)

I enjoy this. But when I wanted to test it on ICS and JB devices/emulators, I saw...

https://dl.dropbox.com/u/49293039/problem1.jpg

As you see, my buttons are not displaying. Let me provide you a quick look into my source code:

@layout/my_dialog.xml, part of buttons bar implementation:

 <LinearLayout
    android:layout_width="match_parent"
    android:layout_height="48dp"
    android:layout_margin="0dp" 
    android:orientation="vertical"
    android:padding="0dp">

    <View
    style="@style/HorizontalDivider"
    />

    <LinearLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_margin="0dp" 
    android:orientation="horizontal"
    android:padding="0dp">

        <Button
        android:id="@+id/cancelButton"
        android:text="@string/cancel_button"
        style="@style/HoloBarButton"
         />

       <View
       style="@style/VerticalDivider"
       />

       <Button
       android:id="@+id/proceedButton"
       android:text="@string/add_button"
       style="@style/HoloBarButton"/>

    </LinearLayout>
</LinearLayout>

@values/styles.xml

<style name="HorizontalDivider">
    <item name="android:layout_width">wrap_content</item>
    <item name="android:layout_height">1dp</item>
    <item name="android:background">?android:attr/listDivider</item>
    <item name="android:layout_margin">0dp</item>
</style>

<style name="VerticalDivider">
    <item name="android:layout_width">1dp</item>
    <item name="android:layout_height">wrap_content</item>
    <item name="android:background">?android:attr/listDivider</item>
    <item name="android:layout_margin">0dp</item>
</style>

<style name="HoloBarButton">
    <item name="android:layout_width">match_parent</item>
    <item name="android:layout_height">match_parent</item>
    <item name="android:background">@android:color/transparent</item>
    <item name="android:layout_margin">0dp</item>
    <item name="android:textColor">#ffffff</item>
    <item name="android:layout_weight">50</item>
</style>

Any ideas how to solve this issue? Implementing two two versions of dialogs (both native for 4.0+ and custom for older Android versions) will bring much more effort. Is it possible to fix it or simply is there any my fault?

I've tried to solve it by changing targetSdkVersion from 15 to 8 and 10 (min is 8), but it didn't help. If something is not clear, please ask. Thanks for your effort.


Solution

  • I solved it. Problem was in part of code, which I did not post there. It was code in @layout/my_dialog.xml. One of LinearLayout had match_parent in layout:height, so there was no room for LinearLayout with my buttons. Surprisingly, older APIs have no problem with that. So be sure about layout parameters and do not trust in correct displaying on one platform, try to run your apps on every one and if something is wrong, look for errors in your code.