在Android Studio中。正在关注有关GridLayout的YouTube教程。尝试将GridLayout的layout_width和height设置为wrap_content并为其添加一个按钮。但是我看不到按钮,或者我通常添加的其他任何东西。

任何想法如何解决这个问题?

图片:

我正在尝试关注this视频

他看不到所有按钮和文字,我看不到

XML文本代码:

<?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代码(不需要):

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);
    }
}

最佳答案

来自Github链接:https://github.com/buckyroberts/Source-Code-from-Tutorials/tree/master/Android_Beginners/017%20GridLayout

使用GridLayout代替android.support.v7.widget.GridLayout

关于java - 在GridLayout中看不到按钮,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/52048559/

10-11 02:32
查看更多