Android 显示GB和IC差异的按钮-带ABS的IC上不可见的按钮

Android 显示GB和IC差异的按钮-带ABS的IC上不可见的按钮,android,dialog,actionbarsherlock,Android,Dialog,Actionbarsherlock,我解决了许多堆栈溢出问题。我面临着具体的问题,所以是时候第一次直接问你了 我用ActionBarSherlock。我希望我的应用程序在任何设备上看起来都一样。我需要对话框,所以我决定使用ABS的对话框主题。因此,我为我的自定义对话框创建了一个活动,并将其样式设置为类似于早期Android版本上的Holo 这就是Android 2.3.3 emulator上的外观: (对不起,由于缺乏声誉,我无法将其作为图片发布…) 我喜欢这个。但当我想在IC和JB设备/模拟器上测试它时,我看到 如您所见,我的

我解决了许多堆栈溢出问题。我面临着具体的问题,所以是时候第一次直接问你了

我用ActionBarSherlock。我希望我的应用程序在任何设备上看起来都一样。我需要对话框,所以我决定使用ABS的对话框主题。因此,我为我的自定义对话框创建了一个活动,并将其样式设置为类似于早期Android版本上的Holo

这就是Android 2.3.3 emulator上的外观:

(对不起,由于缺乏声誉,我无法将其作为图片发布…)

我喜欢这个。但当我想在IC和JB设备/模拟器上测试它时,我看到

如您所见,我的按钮没有显示。让我快速浏览一下我的源代码:

@layout/my_dialog.xml,按钮栏实现的一部分:

 <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>

包装内容
1dp
?android:attr/listDivider
0dp
1dp
包装内容
?android:attr/listDivider
0dp
匹配父项
匹配父项
@android:彩色/透明
0dp
#ffffff
50
有没有办法解决这个问题?实现两个版本的对话框(对于4.0+来说都是本机的,对于旧的Android版本来说都是自定义的)将带来更多的努力。是否有可能修复它,或者只是有任何我的错

我试图通过将targetSdkVersion从15改为8和10(min为8)来解决这个问题,但没有效果。
如果有什么不清楚的,请询问。谢谢您的努力。

问题在于您的按钮样式,请将您的
HoloBarButton
更改为此

<style name="HoloBarButton">
  <item name="android:layout_width">0dp</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">1</item>
</style>

0dp
匹配父项
@android:彩色/透明
0dp
#ffffff
1.

我解决了它。问题出在代码的一部分,我并没有在那个里发布。这是@layout/my_dialog.xml中的代码。其中一个LinearLayout在布局中具有匹配父项:高度,因此没有空间使用我的按钮进行LinearLayout。令人惊讶的是,较旧的API对此没有问题。因此,请确定布局参数,不要相信在一个平台上正确显示,尝试在每个平台上运行应用程序,如果出现错误,请查找代码中的错误。

遗憾的是,不是这样。按钮仍不显示。谢谢你的回复。