简体   繁体   English

无法在Android Studio 2.3.2中以网格布局拖放ImageView

[英]unable to drag and drop ImageView in grid layout in android studio 2.3.2

is it form android studio 2.3+ google has changed how to use grid layout. 是Android Studio 2.3+的形式吗?Google更改了网格布局的使用方式。 I was trying to make a tic tac toe game and i made a 3X3 grid layout but i am unable to put ImageView into it..!! 我试图做一个井字游戏,我做了一个3X3的网格布局,但是我无法将ImageView放进去。

This is the XML file 这是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="match_parent"
android:layout_height="match_parent"
tools:context="com.example.neerajm.tictacbasic.MainActivity">

<GridLayout
    android:layout_width="match_parent"
    android:layout_height="360dp"
    android:layout_marginBottom="8dp"
    android:background="@drawable/board"
    android:columnCount="3"
    android:rowCount="3"
    app:layout_constraintBottom_toBottomOf="parent"
    app:layout_constraintHorizontal_bias="0.0"
    app:layout_constraintLeft_toLeftOf="parent"
    app:layout_constraintRight_toRightOf="parent"
    app:layout_constraintTop_toTopOf="parent"
    app:layout_constraintVertical_bias="0.797"
    android:layout_marginTop="8dp">

</GridLayout>

</android.support.constraint.ConstraintLayout>

I think first you have to Create Class and inside main activity make an object that class And put in your grid layout 我认为首先您必须创建类,然后在主要活动中创建一个该类的对象并放入网格布局中

class Bdfd extends ImageView Bdfd类扩展了ImageView

MainActivity gridlayout gl Bdfd object=new Bdfd ; MainActivity gridlayout gl Bdfd object = new Bdfd; gl.AddView(bdfd); gl.AddView(bdfd);

If I understand your question.It Must to be something like that.. 如果我理解您的问题,那一定是这样。

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

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