简体   繁体   English

按钮未显示在android应用中

[英]Button doesn't show up on android app

I'm making a simple android app with a button but it doesn't wanna appear and I really don't understand why. 我正在制作一个带有按钮的简单android应用程序,但它不想出现,我真的不明白为什么。 This is my code: 这是我的代码:

 <?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:paddingBottom="@dimen/activity_vertical_margin"
    android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin"
    tools:context="com.example.pressme_alpha.MainActivity" >

    <TextView 
        android:id="@+id/score"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginTop="5dp"
        android:layout_marginLeft="5dp"
        android:layout_marginStart="5dp"
        android:text=""
        android:textSize="20sp" />

    <TextView 
        android:id="@+id/money"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginTop="5dp"
        android:layout_marginRight="5dp"
        android:layout_marginEnd="5dp"
        android:layout_alignParentRight="true"
        android:layout_alignParentEnd="true"
        android:text=""
        android:textSize="20sp" />

    <Button
        android:id="@+id/button"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_centerHorizontal="true"
        android:layout_centerVertical="true"
        android:text="@string/press_me"
        android:textSize="30sp"
        android:onClick="handleButtonClick" />

</RelativeLayout>

When I open the app, the Text works and shows up, but the button just doesn't appear. 当我打开应用程序时,文本会显示并显示出来,但按钮不会出现。

I tried running this code and the button does show up. 我尝试运行此代码,但按钮确实出现了。 However there's no additional text as both of your TextView score and money have text set to blank -==> android:text="" The button appears with the text "Press me" on it. 但是,没有其他文本,因为您的TextView得分和金钱都将文本设置为空白-==> android:text =“”随即出现带有文本“ Press me”的按钮。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM