Android Studio 3.2.1 design view is broken - android

The problem
I've started to notice that my Android Studio is showing some weird glitches lately when I'm working with layout files. It started by randomly breaking AS GUI, which was solved by a restart.
But since today, every time I try to open the design view, it breaks.
The picture below will show what I mean:
As you can see, the UI is completely broken, I can't see most of the buttons, and sometimes not even that layout preview shows up. Is this a known issue?
I'm running Android Studio 3.2.1 stable on Windows 10 x64.
What I've tried so far
I have tried to:
Close AS and open it again;
Clean project;
Rebuild project;
Uninstall and reinstall AS;
Uninstall AS, remove the SDK, gradle caches, and everything related to Android, and then reinstall it again and let it download everything once more.
None of those things worked, unfortunately.
And for the sake of completeness, here's the layout I'm using:
<?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="wrap_content">
<ImageView
android:id="#+id/backdrop"
android:layout_width="40dp"
android:layout_height="40dp"
android:layout_marginTop="8dp"
android:layout_marginBottom="8dp"
android:importantForAccessibility="no"
android:src="#color/mds_indigo_400"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent"/>
<android.support.v7.widget.AppCompatTextView
android:id="#+id/letter"
android:layout_width="0dp"
android:layout_height="0dp"
android:gravity="center"
app:autoSizeTextType="uniform"
app:autoSizeMinTextSize="14sp"
app:autoSizeMaxTextSize="26sp"
android:maxLines="1"
android:textColor="#color/secondaryLightText"
app:layout_constraintTop_toTopOf="#id/backdrop"
app:layout_constraintBottom_toBottomOf="#id/backdrop"
app:layout_constraintStart_toStartOf="#id/backdrop"
app:layout_constraintEnd_toEndOf="#id/backdrop"
tools:text="M" />
<TextView
style="#style/TextAppearance.AppCompat.Large"
android:id="#+id/name"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:layout_marginEnd="16dp"
android:textColor="#color/colorAccentDark"
app:layout_constraintStart_toEndOf="#id/backdrop"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="#id/backdrop"
app:layout_constraintBottom_toBottomOf="#id/backdrop"
app:layout_constrainedHeight="true"
tools:text="Marketing"/>
</android.support.constraint.ConstraintLayout>

Related

Android Studio preview goes blank when I add <com.google.android.material.textfield.TextInputEditText>

In any Android app that I have developed, I personally prefer the com.google.android.material.textfield.TextInputEditText view, rather than the plain EditText, just as, in my opinion, it looks much nicer in any and every way possible.
The problem, though, with using com.google.android.material.textfield.TextInputEditText, the preview in Android Studio goes blank. It is difficult to design UI when you cannot preview it except by compiling, and running the actual app on the device.
Here is my fragment_world.xml file:
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.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"
xmlns:app="http://schemas.android.com/apk/res-auto"
tools:context=".WorldFragment">
<com.google.android.material.textfield.TextInputLayout
android:id="#+id/textField"
android:layout_width="0dp"
android:layout_height="wrap_content"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent">
<com.google.android.material.textfield.TextInputEditText
android:id="#+id/editText"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Hello, world!" />
</com.google.android.material.textfield.TextInputLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
As you can see, nothing out of the ordinary is going on here. The preview showed just fine before I added the com.google.android.material.textfield.TextInputEditText view into the layout. Now, the preview goes blank. If I switch to a different tab, and switch back, I can see the outlines of each view in the layout, but it quickly reverts back to its previous, blank state.
I have attempted to create a new, clean project, with nothing in it except this layout here:
<com.google.android.material.textfield.TextInputLayout
android:id="#+id/textField"
android:layout_width="0dp"
android:layout_height="wrap_content"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent">
<com.google.android.material.textfield.TextInputEditText
android:id="#+id/editText"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Hello, world!" />
</com.google.android.material.textfield.TextInputLayout>
That did not work, the same exact thing happened.

In design, EditText error "Render problem" in android

i have error with EditText is "render problem" in design in android when i drag and drop "Plain Text" from Palette to frame design. But when i run app, app run and show normally in genymotion.
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.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=".MainActivity">
<TextView
android:id="#+id/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"
app:layout_constraintVertical_bias="0.122" />
<EditText
android:id="#+id/editTextTextPersonName"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="92dp"
android:ems="10"
android:inputType="textPersonName"
android:text="Name"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/textView" />
</androidx.constraintlayout.widget.ConstraintLayout>
thank you!
i solved this by change rendering engine (below the message Rendering problem). Sry. forgot to take a screenshot :P
Best way is to let android studio instruct you what could be possibly done a manner; efficient & standardized for developer by pressing alt+enter or following tip icon & applying the changes.
One thing you need to always remember is that "when you are using drag and drop feature in the android studio you need to extract string resources for every component
see this image of my code
In this code, the text view type is not specified in most cases like you there is an error for Hardcoded string. try to use ALT+Enter for specifically required operation on this particular component.

Android Studio does not show components on design view, but shows on emulator, any idea why? [duplicate]

This question already has answers here:
Android Studio does not show layout preview
(34 answers)
Closed 4 years ago.
I just started with the Build your first app tutorial from android.com but for some reason, the design view does not show anything I drag or drop to it. I've tried creating buttons, text, plaintext etc, all with no errors, however, I can only see it when I run the app. What am I missing?
Running Android studio 3.1.4 on Ubuntu 18.04.1 LTS.
This is my first time using it, and I searched for similar questions before posting and only found questions/answers that were not similar enough to my issue to be helpful. I have tried rebuilding and invalidating the cache/restart with no avail.
Here are some snaps:
Snap of studio
Snap of emulator
Last here is the 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:id="#+id/container"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">
<TextView
android:id="#+id/message"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="#dimen/activity_horizontal_margin"
android:layout_marginStart="#dimen/activity_horizontal_margin"
android:layout_marginTop="#dimen/activity_vertical_margin"
android:text="#string/title_home"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<android.support.design.widget.BottomNavigationView
android:id="#+id/navigation"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginEnd="0dp"
android:layout_marginStart="0dp"
android:background="?android:attr/windowBackground"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:menu="#menu/navigation" />
<EditText
android:id="#+id/editText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ems="10"
android:inputType="textPersonName"
android:text="KoDy Abbott"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</android.support.constraint.ConstraintLayout>
Please let me know if you need anything else to help answer my question. Thank you in advanced, hopefully it is something simple that I am overlooking but at this point its easier for me to ask then bang my head for another few hours.....
There is no error in your project but there are some bugs in the recent update of support libraries
Change support libraries version to 28.0.0-alpha1 and it will work all
implementation 'com.android.support:appcompat-v7:28.0.0-alpha1'
implementation 'com.android.support:design:28.0.0-alpha1'
Other solutions is that you can find an image button on the up-left. Click it and you can find a option called "force to refresh layout", click it and you problem will be solved.

Created a simple button in Android Studio and nothing appears

I'm new on Android Studio and I just want to create a button who open an URL. For that, I have just created a basic activity from the software. When I try to drag and drop on the design nothing is happening.
Here it is the screenshoot
<?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=".MainActivity">
<Button
android:id="#+id/button2"
style="#android:style/Widget.DeviceDefault.Button"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_marginBottom="24dp"
android:layout_marginEnd="32dp"
android:layout_marginRight="32dp"
android:textAppearance="#style/TextAppearance.AppCompat.Button"
android:visibility="visible"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent"
tools:text="Test" />
<TextView
android:id="#+id/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" />
</android.support.constraint.ConstraintLayout>
There is a
app:layout_constraintStart_toStartOf="parent"
missing on your button. You defined it with 0dp width, so it will scale first if you define left and right constraints.
0dp width or height inside a ConstraintLayout means, that the View will take as much space as possible with the defined Constraint attributes. You missed one for the width scaling, so it will stay 0dp.
If problem persist just follow these steps:
File> Invalid cache/Restart > Invalidate and Restart
It will then surely work
Update :
I get this problems too but it works by Choosing another theme
Problem solved by #I_A_Mok with this problem: Why doesn't the layout design preview get displayed on my Android Studio?
"Change Theme in Editor from App Theme to anything with .NoActionBar (e.g. AppCompat.NoActionBar)."
and this is working! thanks a lot! :D

Android Studio Constraints not showing [Android Studio 3.1.3]

As shown in the image, the constraints are not visible besides activating them.
I have no idea how to solve this problem.
Thanks.
[Edit]
Here is the XML Code, i haven't changed anything just added the Elements on the Design Tab.
<?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:layout_editor_absoluteX="0dp"
tools:layout_editor_absoluteY="81dp">
<Button
android:id="#+id/btn_jump"
android:layout_width="128dp"
android:layout_height="48dp"
android:text="Jump Activity"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent"
tools:layout_constraintBottom_creator="1"
tools:layout_constraintLeft_creator="1"
tools:layout_constraintRight_creator="1"
tools:layout_constraintTop_creator="1" />
<EditText
android:id="#+id/edt_Name"
android:layout_width="215dp"
android:layout_height="43dp"
android:layout_marginTop="107dp"
android:ems="10"
android:inputType="textPersonName"
android:text=""
app:layout_constraintHorizontal_bias="0.502"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent"
tools:layout_constraintLeft_creator="1"
tools:layout_constraintRight_creator="1"
tools:layout_constraintTop_creator="1" />
</android.support.constraint.ConstraintLayout>
It is happen In Android Studio 3.1.3 when We are using appcompact-v7:28.0.0-alpha3 library (It automatically take this library). Open the build.gradle (Module:app) and check in the dependencies that which version of appcompact are you using. If "com.android.support:appcompat-v7:28.0.0-alpha3" then just changed the alpha3 to alpha1 or you can use the previous version 27 also. Now you can see it all component in the blueprint.
Well this is a known issue in appCompat library version v7-28.0.0alpha/ which is being used directly with the latest build tools!
there are two solutions to this!
either upgrade your build tools from your sdk manager's tools tab!
or second way
is reverting back to 27.1.1
change the highlighted one into as
My version version of Android Studio (v3.1.4) has a slightly different line of code for appcompact with no mention of alpha3
implementation 'com.android.support:appcompact-v7:28.0.0-rc01' so i just changed it to
above version 27 and clicked Sync Project With Gradle Files and it now shows the constraints perfectly.

Categories

Resources