Android Tools Attributes edit

Designtime Layout Attributes

These attributes are used when the layout is rendered in Android Studio, but have no impact on the runtime.

In general you can use any Android framework attribute, just using the tools: namespace rather than the android: namespace for layout preview. You can add both the android: namespace attribute (which is used at runtime) and the matching tools: attribute (which overrides the runtime attribute in the layout preview only).

Just define the tools namespace as described in the remarks section.

For example the text attribute:

<EditText 
      tools:text="My Text"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content" />

Or the visibility attribute to unset a view for preview:

<LinearLayout
        android:id="@+id/ll1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        tools:visibility="gone" />

Or the context attribute to associate the layout with activity or fragment

<LinearLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    tools:context=".MainActivity" >

Or the showIn attribute to see and included layout preview in another layout

<EditText xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="@string/text"
    tools:showIn="@layout/activity_main" />

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:

Tools Attributes/
Tools Attributes
Designtime Layout Attributes

Table Of Contents
39 ACRA
53 Tools Attributes
64 Menu
112 Loader
119 Xposed
132 Colors
135 Fresco
140 AdMob
147 Button
156 Vk SDK
170 XMPP
176 OpenCV
200 FileIO
203 Moshi
217 Paint
231 AIDL
241 JCodec
243 Okio
255 Looper
  ↑ ↓ to navigate     ↵ to select     Esc to close