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.
Related
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...).
When I do changes to a layout resource file it's not updated/reflected when the apk file is buildt and installed from Android Studio 2.0 (Preview 3b).
Example:
I had a EditText and I added a TextInputLayout like this:
<android.support.design.widget.TextInputLayout
android:id="#+id/input_layout_new_password"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="8dp">
<EditText
android:id="#+id/edit_text_new_password"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="#string/hint_your_new_password"
android:inputType="textPassword"
android:saveEnabled="false" />
</android.support.design.widget.TextInputLayout>
The result after updating the app is the same as before I added the TextInputLayout, just the EditText without TextInputLayout.
What I've tried:
Build/Clean Project
Build/Rebuild Project
File/Invalidate Caches / Restart..
Uninstall app first
Turn off Instant Run
I suspect this is probably a bug with the Preview 3b version of Android Studio 2.0 causing this. Any ideas? Maybe it's just a settings/configuration?
Temporary solution:
If you make a copy of the layout file and inflate it instead. Then the changes are updated in the app? But this is not ideally the best solution!
Also make sure you make the changes in the layout-v<target-api> folder if you have set specific layout for specific api level. For example layout-v23 in mine case.
This issue is typically caused by only updating the xml file in one layout folder and not the other folders containing the file's compatibility variants as well. For example, only editing the xml file in the layout system folder and not the layout-v14 folder too will cause this issue.
The fix: update the instance of the layout xml file not only in your layout folder, but the instances in all other layout folders too (layout-v14, layout v-21, etc.)
I wasn't able to reproduce this issue. I tried the same layout changes with Preview 3b and the changes showed up in the emulator fine. I simply hit the run button again.
Was this working for you in a previous version of Android Studio?
I'm trying to use the "tools" namespace feature in Android Studio.
I'm trying to populate the ListView with dummy list items, for design purposes. The link here says the tools:listitem="#android:layout/<filename>" should do.
But for some reason, Android Studio keeps showing Layout android:<filename> does not exist. I'm trying to find a solution for it, so I don't have to run my app again and again with dummy values for testing.
I might be overlooking something very foolish, so forgive me. Here is what I have for now:
<ListView
android:id="#+id/controllerProfiles"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="20dp"
tools:listitem="#android:layout/profiles_list_item"/>
And I have a file profiles_list_item.xml under res/layout. Any suggestions or alternatives?
you should change the following line :
tools:listitem="#android:layout/profiles_list_item"
to this :
tools:listitem="#layout/profiles_list_item"
with #android you say that you want to use a layout from android resources but your layout is in your own project files.
tools:listitem doesn't work with ListViews in Android Studio 2.2. This is a known bug. I've tested this in Android Studio 2.3 beta 1 and it is fixed here.
You can also move from ListView to RecyclerView as this bug doesn't occur at RecyclerViews.
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.
I just did an update of my SDK and now eclipse is giving me all sorts of totally unwanted warnings in my xml... for example I have a RelativeLayout that doesn't have an id or a background (it's actually a transparent button) and eclipse is warning me that it's a useless element. Is there a way to turn this idiocy off?
TIA
According to the documentation at http://tools.android.com/recent/ignoringlintwarnings you do this by including the tools xmlns:
xmlns:tools="http://schemas.android.com/tools"
And then adding a tools:ignore annotation in the relevant elements:
<RelativeLayout
tools:ignore="UselessParent"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="30dp"
android:layout_centerInParent="true">
This still works perfectly in 2022.
In New Update of Eclipse ADT Plugins will give you New Tool Which Name is Lint here is one SO Link for this tool and it's advantages .Click Here
Now for Disable xml Warnings that are come from Lint Android Tool ,you need to go
Window-->Preferences-->Android-->Lint Error Checking
in this Dialog you will find all Issue for Xml in android and you can make disable it ,if you want to disable.And Make sure you will not disable usefull lint warning because it's help us to find there are multiple ID assign in xml and lot more..