Skip to content

Instantly share code, notes, and snippets.

@rosuH
Created November 3, 2017 08:01
Show Gist options
  • Save rosuH/4badf99e07f7b0a093d8cd26dfd3e5cd to your computer and use it in GitHub Desktop.
Save rosuH/4badf99e07f7b0a093d8cd26dfd3e5cd to your computer and use it in GitHub Desktop.
Preview the layout during editing XML files.
<?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:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context="com.example.PreviewLayoutActivity">
<TextView
android:id="@+id/answer_text_view"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="24dp"
tools:text="Answer"/>
</LinearLayout>
@rosuH
Copy link
Author

rosuH commented Nov 3, 2017

  1. Adding tools:context="your.activity" to super layout
  2. Using tools:text="Strings you want to preview" in the compotent which you want to preview

The string Answer will only display in the Android Studio preview window and wont show in running app.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment