Reputation: 81
In Android Studio. Was following a youtube tutorial about GridLayout. Trying to use GridLayout with layout_width and height that set to wrap_content and add a button to it. But I can't see the button, or anything else I add normally.
Any idea how to fix this?
Picture:
I was trying to follow this video
He can see all of the button + text, I cant
XML Text code:
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
tools:context=".MainActivity">
<android.support.v7.widget.GridLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
tools:layout_editor_absoluteX="8dp"
tools:layout_editor_absoluteY="8dp">
<Button
android:id="@+id/button6"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Button"
tools:layout_editor_absoluteX="0dp"
tools:layout_editor_absoluteY="0dp" />
</android.support.v7.widget.GridLayout>
</android.support.constraint.ConstraintLayout>
Java code (Don't think needed):
package com.example.naveh.layla;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
}
Upvotes: 2
Views: 996
Reputation: 1
Try using GridLayout instead of androidx.gridlayout.widget.GridLayout.
This helped me.
Upvotes: 0
Reputation: 12803
From Github link : https://github.com/buckyroberts/Source-Code-from-Tutorials/tree/master/Android_Beginners/017%20GridLayout
Use GridLayout
instead of android.support.v7.widget.GridLayout
Upvotes: 1
Reputation: 293
I tried to run the code in my machine, It's works fine. Button is visible. Please try to change the theme of your preview section, and also run on real device.
Upvotes: 0