2011-06-20 28 views
0

我有以下布局:按钮背景hidding按钮文本。为什么?

<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    android:id="@+id/widget30" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 

    android:background="@drawable/v_fundo" 
> 
<ImageView 
    android:id="@+id/imageView1" 
    android:layout_height="wrap_content" 
    android:src="@drawable/v_titulo" 
    android:layout_width="wrap_content" 
    android:layout_alignParentLeft="true"> 
</ImageView> 
<RelativeLayout android:layout_height="wrap_content" android:id="@+id/relativeLayout2" android:layout_width="wrap_content" android:layout_alignParentBottom="true" android:layout_alignParentRight="true"> 
     <ImageView android:id="@+id/widget32" android:layout_height="wrap_content" android:layout_width="wrap_content" android:background="@drawable/v_personagem">  </ImageView> 
     <Button android:layout_height="wrap_content" android:background="@drawable/v_balao" android:layout_width="wrap_content" android:id="@+id/lastComicButton"></Button> 
    </RelativeLayout> 
    <ImageView android:src="@drawable/v_transparente" android:layout_height="wrap_content" android:layout_width="wrap_content" android:id="@+id/imageView2" android:layout_alignParentBottom="true"></ImageView> 
    <RelativeLayout android:layout_height="wrap_content" android:layout_width="wrap_content" android:id="@+id/relativeLayout1" android:background="@drawable/funcoes_fundo" android:layout_above="@+id/imageView2" android:layout_alignLeft="@+id/imageView2" android:layout_alignRight="@+id/imageView2"> 
     <Button android:layout_height="wrap_content" 
      android:layout_alignParentTop="true" 
      android:layout_width="wrap_content" 
      android:id="@+id/button2" 
      android:text="Yes, we can!" 
      android:background="@drawable/funcoes_1"> 
     </Button> 
     <Button android:layout_height="65dp" 
      android:layout_alignRight="@+id/button2" 
      android:layout_alignLeft="@+id/button2" 
      android:layout_width="250dp" 
      android:id="@+id/button1" 
      android:layout_below="@+id/button2" 
      android:background="@drawable/funcoes_2"> 
     </Button> 
    </RelativeLayout> 

与ID button2android:id="@+id/button2")按钮显示在模拟器上的里程碑二代文本罚款。

但是,当我将.apk放入摩托罗拉Defy时,按钮的图像背景隐藏其文本(“是的,我们可以!”)。我相信这一点,因为如果我不显示背景(通过删除行android:background="@drawable/funcoes_1"),文本在按钮中显示得很好。

有没有人有任何线索,为什么按钮的背景图像隐藏它的文字在一些设备(如摩托罗拉Defy)?

预先感谢您!

+0

你的布局代码是错的。你应该永远不要做'android:layout_alignRight = @ + id/blah'它应该只是'@ id/blah',因为你已经在你的R.java文件中定义了ID – hwrdprkns

+1

我已经解决了这个问题。出于某种原因,摩托罗拉Defy上的文本的默认颜色是白色的。而且,一旦我的背景也是白色的,我无法看到文字。所以,我需要做的就是将textcolor设置为黑色(#000000)。 –

回答

0
android:layout_alignRight="@+id/button2" 
android:layout_alignLeft="@+id/button2" 
android:layout_below="@+id/button2" 

这些都应设置为“true”或“false”。这些属性用于在RelativeLayout中确定成员的“相对”重力/对齐。

声明android:id =“@ + button2”就足够了。

可能发生的事情是,它无法使用的设备具有旧版本或不同版本的Android,因此无法容忍此错误。

希望这有助于。