Invisible buttons in the emulator but visible in the preview

5

Why do not the buttons I create in xml show up in avd? In the layout they appear with a gray color, however when boto to run in the emulator they are simply invisible. If I put some text in the button, the text appears, but the button does not. I'm following the tutorial to create this game and did nothing different, but mine is like this.

My xml file:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:orientation="vertical">

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal">

        <Button
            android:layout_width="100dp"
            android:layout_height="100dp"
            android:tag="quadrado1"
            android:onClick="clickQuadrado" />

        <Button
            android:layout_width="100dp"
            android:layout_height="100dp"
            android:tag="quadrado2"
            android:onClick="clickQuadrado" />

        <Button
            android:layout_width="100dp"
            android:layout_height="100dp"
            android:tag="quadrado3"
            android:onClick="clickQuadrado" />
    </LinearLayout>

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal">

        <Button
            android:layout_width="100dp"
            android:layout_height="100dp"
            android:tag="quadrado4"
            android:onClick="clickQuadrado" />

        <Button
            android:layout_width="100dp"
            android:layout_height="100dp"
            android:tag="quadrado5"
            android:onClick="clickQuadrado" />

        <Button
            android:layout_width="100dp"
            android:layout_height="100dp"
            android:tag="quadrado6"
            android:onClick="clickQuadrado" />
    </LinearLayout>

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal">

        <Button
            android:layout_width="100dp"
            android:layout_height="100dp"
            android:tag="quadrado7"
            android:onClick="clickQuadrado" />

        <Button
            android:layout_width="100dp"
            android:layout_height="100dp"
            android:tag="quadrado8"
            android:onClick="clickQuadrado" />

        <Button
            android:layout_width="100dp"
            android:layout_height="100dp"
            android:tag="quadrado9"
            android:onClick="clickQuadrado" />
    </LinearLayout>
</LinearLayout>
    
asked by anonymous 13.04.2015 / 19:46

1 answer

2

I tested it on Android Studio with your xml , it shows the button normally on my virtual machine.

Try this scope for each button:

<Button
                android:layout_width="100dp"
                android:layout_height="100dp"
                android:id="@+id/buttonX"
                android:layout_gravity="center_horizontal" 
                android:onClick="clickQuadrado"/> 
    
31.03.2016 / 00:04