Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can't see elements layout android studio in activity_main.xml

I'm beginning with android studio and I can't see the elements (Buttons,TextView,..) I drag and drop in my Design page in activity_main.xml page. Those elements are present in my XML file and I can see them when I run my app on my device but I don't know how I can see them on "Design and Blueprint" page.

Thanks for your help.

This is my xml code :

<?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"
    tools:layout_editor_absoluteY="25dp">

    <TextView
        android:id="@+id/message"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="@string/title_home"
        app:layout_constraintBottom_toTopOf="parent"
        app:layout_constraintEnd_toStartOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent" />

    <android.support.design.widget.BottomNavigationView
        android:id="@+id/navigation"
        android:layout_width="1dp"
        android:layout_height="wrap_content"
        android:background="?android:attr/windowBackground"
        app:layout_constraintBottom_toTopOf="parent"
        app:layout_constraintEnd_toStartOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent"
        app:menu="@menu/navigation" />

    <Button
        android:id="@+id/button"
        android:layout_width="12dp"
        android:layout_height="12dp"
        android:text="ClickMe"
        tools:layout_editor_absoluteX="-73dp"
        tools:layout_editor_absoluteY="29dp" />

    <android.support.constraint.Guideline
        android:id="@+id/guideline"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:orientation="vertical"
        app:layout_constraintGuide_begin="20dp" />


</android.support.constraint.ConstraintLayout>

And my canvas is totally empty.

EDIT :

I'v got 2 errors :

  • Render Problem : Failed to find style 'bottomNavigationStyle' in current theme Tip: Try to refresh the layout.

  • Missing Constraints in ConstraintLayout : This view is not constrained. It only has designtime positions, so it will jump to (0,0) at runtime unless you add the constraints

like image 461
user9007028 Avatar asked Jun 17 '18 13:06

user9007028


2 Answers

You can solve this problem by fixing the styles.xml file.

find the styles.xml

Then you just have to add Base in this code:

<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">

The final code:

<style name="AppTheme" parent="Base.Theme.AppCompat.Light.DarkActionBar">
like image 69
Johira Afzali Avatar answered Oct 16 '22 18:10

Johira Afzali


If you have the same error as this page, you should change com.android.support:appcompat-v7:28.0.0-alpha3 to com.android.support:appcompat-v7:28.0.0-alpha1 in build.gradle(Module: app) and and click File -> Invalidate Caches / Restart. Now everything is OK.

enter image description here

Of course you need internet access to download com.android.support:appcompat-v7:28.0.0-alpha1

like image 4
Hossein Seifi Avatar answered Oct 16 '22 19:10

Hossein Seifi