在GB和ICS上显示差异的按钮 - 在带有ABS的ICS上看不到的按钮
我解决了堆栈溢出的许多问题。我遇到了特殊的问题,所以现在是时候直接问你第一次了。在GB和ICS上显示差异的按钮 - 在带有ABS的ICS上看不到的按钮
我使用ActionBarSherlock。我希望我的应用在任何设备上看起来都一样。我需要对话框,所以我决定使用ABS的对话框主题。所以我为我的自定义对话框创建了一个活动,并且我将它设计成即使在早期的Android版本上也像Holo。
这就是它是如何看在Android 2.3.3模拟器:
https://dl.dropbox.com/u/49293039/problem2.jpg(对不起,我不能发布它作为一个图像由于缺少我的名誉......的)
我喜欢这一点。但是,当我想测试它ICS和JB设备/仿真器,我看到...
https://dl.dropbox.com/u/49293039/problem1.jpg
正如你看到的,我的按钮没有显示。让我为您提供一个快速查看我的源代码:
@布局/ 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>
@价值观/ 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>
任何想法如何解决这个问题?实现两个版本的对话框(本地版本为4.0以上,而旧版本为Android版本)将带来更多的努力。是否有可能解决这个问题,或者是否有我的错?
我试图通过将targetSdkVersion从15更改为8和10(最小为8)来解决它,但它没有帮助。 如果不清楚,请询问。谢谢你的努力。
我解决它。问题出在部分代码中,我没有在那里发布。它是@ layout/my_dialog.xml中的代码。 LinearLayout中的一个在layout:height中有match_parent,所以LinearLayout和我的按钮没有空间。令人惊讶的是,旧的API没有问题。因此,请务必确定布局参数,并且不要相信在一个平台上显示正确,尝试在每个平台上运行您的应用程序,如果出现问题,请在您的代码中查找错误。
问题是在你的按钮样式,改变你的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>
不幸的是,这不是。按钮仍然不显示。感谢您的回应。 – 2013-02-24 15:41:05