2014-02-28 17 views
3

我昨天整天都試過,我無法修復它。 我搜索了答案,但沒有發現任何類似於我的問題。 這可能很容易解決,但我不明白。文本沒有顯示在按鈕組件上

我有以下簡單的代碼:

<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    ... ... > 

<LinearLayout 
    ... ... > 


    <Button 
    android:id="@+id/registrarUser" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_gravity="center_horizontal" 
    android:layout_marginTop="10dip" 
    android:gravity="center" 
    android:padding="15dp" 
    android:background="@drawable/button_shape" 
    android:text="@string/registrar" 
    android:textColor="@color/tinto" /> 

    </LinearLayout> 
</RelativeLayout> 

Y不能顯示在按鈕上的文字!

這裏我strings.xml

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

    <string name="app_name">Android GCM</string> 
    <string name="action_settings">Settings</string> 
    <string name="hello_world">Hello world!</string> 
    <string name="btn_aceptar">Aceptar</string> 
    <string name="reg_gcm">Reg GCM</string> 
    <string name="btn_desreg_gcm">DesReg GCM</string> 
    <string name="nombre_usuario">Usuario</string> 
    <string name="registrar">Registrar</string> 

</resources> 

在這裏,我button_shape.xml

<?xml version="1.0" encoding="utf-8"?> 
<shape xmlns:android="http://schemas.android.com/apk/res/android" 
    android:shape="rectangle"> 
    <gradient 
     android:startColor="#80000000" 
     android:endColor="#80f2f2f2" 
     android:angle="-90"/> 
    <padding android:left="7dp" 
     android:top="7dp" 
     android:right="7dp" 
     android:bottom="7dp" /> 
    <corners android:radius="13dp" /> 
</shape> 

即使在拆除android:background="@drawable/button_shape"(我想這可能是這個問題。)但這並沒有工作。

在控制檯中,我可以看到按鈕上顯示正確的文本......但不是當我跑步時我的設備的proyect ... :(

enter image description here 什麼我做錯了什麼?我??是相當新的這個和我找不到錯誤

有人有同樣的事情發生任何建議,請 非常感謝你提前

編輯:!

問題解決了!

我剛剛意識到「LinerarLayout」有一個固定的「高度」設置!這減少了按鈕! 所以,我改變了

"android: layout_height =" 200DP ""android: layout_height =" wrap_content " 這就是全部!

enter image description here

我希望它能幫助別人的東西爲「傻」不要浪費那麼多時間。

感謝和問候!

+0

這是什麼顏色的tinto?嘗試設置黑色,然後看看你是否在運行時重置文本? –

+0

請分享您的Java代碼(活動代碼) –

+0

當我在按鈕上看到文字時,您的活動 –

回答

0

我認爲這個問題是您的按鈕的文本顏色

<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
... ... > 

<LinearLayout 
... ... > 


<Button 
android:id="@+id/registrarUser" 
android:layout_width="wrap_content" 
android:layout_height="wrap_content" 
android:layout_gravity="center_horizontal" 
android:layout_marginTop="10dip" 
android:gravity="center" 
android:padding="15dp" 
android:background="@drawable/button_shape" 
android:text="@string/registrar" 
android:textColor="#000000" /> 

</LinearLayout> 
</RelativeLayout> 

嘗試設置按鈕的文本顏色爲黑色或白色(有史以來最好的對比,你的按鈕背景)
我希望這有助於。

+0

我已經試過了。即使有自己的顏色colors.xml保存,也沒有工作。不管怎麼說,還是要謝謝你! – leonhard4

+0

請分享您的Java代碼,我想這存在一些問題。 –

+0

活動編輯.. – leonhard4