Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/linq/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android EclipseGUI不正确地显示新样式的按钮_Android_Eclipse - Fatal编程技术网

Android EclipseGUI不正确地显示新样式的按钮

Android EclipseGUI不正确地显示新样式的按钮,android,eclipse,Android,Eclipse,我从一个完全工作的应用程序开始,所有的按钮都在正确的位置和大小。。。但是现在我想第一次尝试使用样式。我特别希望按钮中的文本颜色为深蓝色,背景为白色。因此,我在styles.xml中以res/values格式编写了以下内容-> <?xml version="1.0" encoding="utf-8"?> <resources> <style name="mybut" parent="@android:style/Widget.Button">

我从一个完全工作的应用程序开始,所有的按钮都在正确的位置和大小。。。但是现在我想第一次尝试使用样式。我特别希望按钮中的文本颜色为深蓝色,背景为白色。因此,我在styles.xml中以res/values格式编写了以下内容->

<?xml version="1.0" encoding="utf-8"?>
<resources>

   <style name="mybut"  parent="@android:style/Widget.Button">

        <item name="android:textColor">@color/dblue</item>
         <item name="android:background">#ffffffff</item>
    </style>

</resources>

@颜色/蓝色
#ffffffff
我修改了我的按钮代码如下:

    <Button
        android:id="@+id/spec"
        style="@style/mybut"  <-- I added this line here
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_weight="0.12"
        android:text="@string/spec" />

问题一定在这里:

  android:layout_weight="0.12"
如果你在运行应用程序时有一个动作栏或类似的东西,按钮就会缩小。在预览中,动作栏不会出现(我只是猜测)

编辑
这是我在应用程序中使用的一个自定义按钮的示例,我输入了最小高度和宽度。 而不是使用:
parent=“@android:style/Widget.Button”
我使用:
parent=“android:Widget.Button”


@可绘制/btn\u默认\u全息灯
48dip
64dip
#fff

默认情况下,
按钮的背景为9块,而不是简单的颜色。此图像具有填充和内容区域,可更改按钮的实际大小


当你改变背景时,你正在剥离填充物,它看起来更小。正确的方法是在旧的基础上创建一个新的9-patch,但颜色发生了变化。

谢谢,但是高度变化(30%?)太剧烈了,这不是问题。@Mick我编辑了答案,你能试试这个解决方案吗?
<style name="ButtonCustom" parent="android:Widget.Button">
    <item name="android:background">@drawable/btn_default_holo_light</item>
    <item name="android:minHeight">48dip</item>
    <item name="android:minWidth">64dip</item>
    <item name="android:textColor">#fff</item>
</style>