java - android.support.constraint.ConstraintLayout error -


the error says need validate android:layout_height/width in code , doesn't have required element of both android:layout_height/width. new java appreciated.

my mainactivity code this:

    package com.example.name.myapplication;      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);         } 

my activity_main.xml code here:

    <?xml version="1.0" encoding="utf-8"?>     <android.support.constraint.constraintlayout         xmlns:android="http://schemas.android.com/apk/res/android"         xmlns:tools="http://schemas.android.com/tools"        tools:context="com.example.name.myapplication.mainactivity">        <tablelayout             xmlns:android="http://schemas.android.com/apk/res/android"            android:id="@+id/table_main"            android:layout_margintop="48dp"            android:layout_width="match_parent"            android:layout_height="48dp"            android:stretchcolumns="1">             <tablerow>                <textview                    android:layout_column="1"                    android:text="@string/name"                    android:padding="3dip" />                 <textview                    android:text="@string/address"                    android:padding="3dip" />                 <textview                    android:text="@string/phone"                    android:gravity="right"                    android:padding="3dip" />                 <textview                    android:text="@string/fax"                    android:gravity="right"                    android:padding="3dip"                    android:layout_height="45dp"/>            </tablerow>      </tablelayout>  </android.support.constraint.constraintlayout> 

it looks haven't added height or width constraints constraint layout. therefore, application has no idea how high or wide make layout.

try adding these under constraint layout:

android:layout_width="match_parent" android:layout_height="match_parent" 

so code this:

<android.support.constraint.constraintlayout     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"     tools:context="com.example.name.myapplication.mainactivity"> 

Comments

Popular posts from this blog

php - Vagrant up error - Uncaught Reflection Exception: Class DOMDocument does not exist -

vue.js - Create hooks for automated testing -

Add new key value to json node in java -