You do not see anything again

5

I'm trying to use Android Studio, but fuck for everything. I put two buttons and you can not see anything.

CLASS

package com.example.jhon.myapplication;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.widget.Button;

public class MainActivity extends AppCompatActivity {

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
}
}

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"
android:maxWidth="@android:dimen/dialog_min_width_minor"
android:visibility="visible"
tools:context=".MainActivity">

<TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="Hello World!"
    app:layout_constraintBottom_toBottomOf="parent"
    app:layout_constraintLeft_toLeftOf="parent"
    app:layout_constraintRight_toRightOf="parent"
    app:layout_constraintTop_toTopOf="parent" />

<Button
    android:id="@+id/button"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="@string/butCliente"
    tools:layout_editor_absoluteX="110dp"
    tools:layout_editor_absoluteY="201dp" />

<Button
    android:id="@+id/button2"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="@string/butTransaccion"
    app:layout_constraintEnd_toEndOf="parent"
    tools:layout_editor_absoluteY="343dp" />

</android.support.constraint.ConstraintLayout>

Should we change something in the code?

Is it that you drag things and by default these are not seen? why is this program like this?

    
asked by Jhon Hernández 11.09.2018 в 10:00
source

2 answers

3

It is an API 28 problem that is not yet stable. I found the solution in this question. As it is in English, I will put what needs to be done

Change in the build.gradle (Module: app) the lines that refer to api 28 for these (they do not have to be together):

compileSdkVersion 27 
targetSdkVersion 27
buildToolsVersion '27.0.3'
implementation 'com.android.support:appcompat-v7:27.1.1'

Compile the project and open the view again

    
answered by 11.09.2018 / 10:24
source
1

you could change this in your XML

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout 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"
 android:orientation="vertical"
 tools:context=".MainActivity">

<TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="Hello World!" />

<Button
    android:id="@+id/button"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="@string/butCliente"/>

<Button
    android:id="@+id/button2"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content" />

</LinearLayout>
    
answered by 11.09.2018 в 14:53