Can anybody how to remove this parent NavDrawer overlay showing whilst designing layout? (Screen 1).
The overlay is removed when running in actual device (Screen 2).
Because of this I can't design child elements right there in the studio.
Any help would be great!
<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.DrawerLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:visibility="visible">
<LinearLayout android:layout_width="match_parent" android:layout_height="match_parent">
<TextView android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Always Visible."
/>
</LinearLayout>
</android.support.v4.widget.DrawerLayout>
When you see that gray block with the tag name in it, that means that Android Studio can't resolve the class from the tag in your layout, so it doesn't know what to preview. Often this will happen if you have a typo in your layout file, but then you wouldn't see it working when you actually run the app.
For me, I can make this happen quite easily by using the old support library versions of widgets, since I have AndroidX enabled in my project. For example, just pasting your code in to my IDE gives me the same gray box, but changing your tags to use AndroidX fixes it (android.support.v4.widget.DrawerLayout -> androidx.drawerlayout.widget.DrawerLayout).
Chances are good that your Android Studio just needs a kick in the pants.
I suggest doing a Gradle Sync (File -> Sync Project with Gradle Files) and, if that doesn't work, an Invalidate + Restart (File -> Invalidate Caches / Restart...).
Related
I am a beginner in android development. I have created a android project. But in the preview section, I am not able to see the components. But components are visible when i run the same app on emulator i am able to see the components. I am missing some setting here? XML is given below.
<?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">
<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>
I've had have also this problem and solved it by only selecting another "Theme" cause
the default theme appTheme doesn't show added items.
If you i.e. select Transulcent, any item becomes visible ;-)
cheers
Oliwan
Maybe sound a weird answer, but self-tested this.
Change the XML file's (maybe activity_x.xml) layout's root tag android.support.constraint.ConstraintLayout to LinearLayout, then preview will start working again (as happened in my case). [If not, then perform force refresh (R)]
Then switch back to old one, I mean: Change the XML file's (maybe activity_x.xml) layout's root tag LinearLayout to android.support.constraint.ConstraintLayout. And force a refresh.
This does seem to be a bug in Android Studio. When it showed up for me, I fixed it by making a trivial change in the app build.gradle (change version code), do a gradle sync, then change back and sync again.
After that, the design view worked again.
I have installed all sdk and correctly installed but I have tried multiple times but I cannot fine frame of app where I can insert tool,widgets, button, etc. (Cannot add anything on workspace)
My Android studio window image: https://drive.google.com/file/d/0B8AWJ5JO_e0xVV9KVEE0TUpMYWc/view?usp=drivesdk
Select devices,sdk and theme,like this
image: https://drive.google.com/open?id=0B7VdJKtF9NwGNVFKeE5zZ2pxVHM
Looks like you've gotten rid of the Component Tree.
Try go to the Text-tab and paste
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
</LinearLayout>
or whatever root layout you need...
My issue is similar to this but Android Studio doesn't tell me anything about a rendering issue or compiler/build errors(I was able to build fine).
Here is what I am seeing(this is a new project)
And the contents of content_main.xml
After reading on different rendering issue threads, I I've tried rebuilding, cleaning, invalidate caches/restart and even starting a new project to see if the layout preview was working(Still empty)
I also played around with different sdk versions(20,19) to see if the layout preview was working but all I got was this quirky issue that I don't think would cause the layout preview to not work.
Does anyone know what my problem is here? I didn't mess around with my initial Gradle files and remove any support library dependencies. Another solution I had in mind was reinstalling Android Studio but that's last resort.
Just check your sdk valid version like example.
Try putting your TextView element into an empty FrameLayout:
<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/my_groups" />
</FrameLayout>
This code above should be put inside your RelativeLayout. Hope it helps.
EDIT : this issue now only happens when I try to have a listview with a preview layout that contains databinding (from android databinding)
In android Studio, when I try to add an item preview for a listview, nothing happens (the default preview is still displayed) and in the splitted version (text + preview) I have a black screen for the preview.
First I was thinking that my layout was somehow too complex, so I tried with a simple layout file, containing only a LinearLayout and a listview. I checked that the listview has an id (and all the solutions I found on stackoverflow) but nothing works. Here is my layout :
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ListView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/listView2"
android:layout_gravity="center_horizontal"
tools:listitem="#layout/item_chat"/>
</LinearLayout>
And here is the screenshot of the result (the preview is supposed to be on the right). I really need to make this work, and the fact is that the same thing happen whenever I try to use tools:something.
I'm using Android Studio 1.4
Edit : I tried to clone a project that where using tools AND data binding, and the preview works!
Hello I had checked again the UI is rendring atleast for one item. In my it is giving "Rendering Problems onLayout error" while rendering but shows one row item. To make it possible you have to make few changes in xml code:
<ListView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="#+id/listView2"
tools:listitem="#layout/item_chat"/>
make sure you are using latest build version tools. I have checked with following:
buildToolsVersion "23.0.0"
classpath 'com.android.tools.build:gradle:1.3.0'
classpath "com.android.databinding:dataBinder:1.0-rc1"
If it still gives try with latest build tools from SDK manager. I have install following plugin in addition:
Android SDK platform-tools version 23.1 rc1 under Tools(Preview channel)
I'm having trouble with eclipse ADT plugin. Everything was ok in Eclipse's layout editor, in both graphical and XML modes. I designed the GUI mostly from the graphical editor, for convenience.
At some point the Properties view broke. Now it only shows properties for the "View" class, and every other property from View subclasses are not shown (for instance, properties of ImageView are not shown). Properties for aligning inside RelativeLayout are also missing (for instance alignParentTop).
This is a "clean" eclipse install I use only for android, there are no other plugins installed (other than subeclipse). It has never failed me before. I've updated the SDK and also the plugin to the last version but it didn't fix this problem. Eclipse is v3.7 Indigo R2.
Also tried cleaning the project to no avail.
Have you seen this behaviour before? Is it possible to get the graphical editor back and fully working as expected without reinstalling everything again?
Thanks in advance.
UPDATED:
I've traced the problem to a single layout XML. Other layout XMLs are working fine. And the problem is that I'm using the DrawerLayout as main layout:
<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android">
If I replace this layout for a regular LinearLayout everything returns back to normal. Still I've to find a solution, because every modificattion attempted on the graphical layout results in that element being removed. So this is probably a bug and not only it is inconvenient but also dangerous!
I had the same problem and managed to fix it by splitting the content of the DrawerLayout out into different files like this:
<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="#+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<!-- The main content view -->
<include layout="#layout/activity_tab_content"/>
<!-- The navigation drawer -->
<include layout="#layout/navigation_drawer"/>
</android.support.v4.widget.DrawerLayout>
Now I can edit the content of the drawer successfully in a separate editor.