Sometimes, you wish to put some placeholders to be shown only on the IDE, in layout files.
As an example, you can use this:
<
What's even the name of this feature?
Unconfirmed by an official source, but it's likely called "Sample Data".
How can I put the image file into the project, and use it as a placeholder this way ? In which folder?
Unlike resources like images, fonts, etc. The sample data does not go in /res/ (they are not compiled with the app, hence. It is probably easier to filter them out by putting them in a totally separate directory). They go in /app/sampledata/, for example: /app/sampledata/image.png.
You can create the sampledata folder by right clicking on app and do New > Sample Data directory:
You can then reference them like this, with @sample/
While this does not give any errors, sadly the feature seems bugged right now, since the images do not show up in the preview, regardless of them being placed in a subdirectory or not (tried png, jpeg, jpg, xml).
Interestingly, placing a single image in a subdirectory and referring to that subdirectory instead of the specific image seems to work:
A structure of this
Combined with these references
Produces this preview. Notice how I utilized tools:background to set the layout background to a sample image.
Is it possible to add more images to be used this way?
Yeah, just add them to the folder.
Is it possible to add other resources? Layouts? Strings?
It does not appear to support either. If you try to define some other type of resource, you either get a bunch of syntax errors due to keywords not being recognized, or you cannot refer to them with the tools:src="@sample/ notation.
Are there more capabilities of this new feature?
Unsure at this time.