5

When adding TextViews and ImageViews to my layouts that will be populated dynamically at runtime, I often add placeholder text and images so I can preview a realistic layout. Can the layout editor do this for me without requiring me to explicitly include these strings and images in my application automatically?

Jeff Axelrod
  • 27,676
  • 31
  • 147
  • 246

2 Answers2

4

It doesn't look like this feature exists, so I created a feature request.

When adding TextViews and ImageViews to my layouts that will be populated dynamically at runtime, I often add placeholder text and images so I can preview a realistic layout.

Please enable the layout editor do this for me without requiring me to explicitly include these strings and images in my application automatically. I assume you'd want to have a default image size in the preferences and allow individual ImageViews/texts to override the defaults with something like tools:defaultImageWidth=123px, tools:defaultText="Lorem Ipsum", etc.

tools:numDefaultLoremIpsumTextChars=80 would generate 80 characters of default text.

Jeff Axelrod
  • 27,676
  • 31
  • 147
  • 246
1

I followed up Jeff's feature request and found out:

I think this ticket pre-dates the work done under the tools namespace:

http://tools.android.com/tips/layout-designtime-attributes

I think that now it is possible to do most everything requested. For setting a placeholder text: tools:text For Images, there is no placeholder image or default size but we can use and android "internal image". Something like:

<ImageView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        tools:src="@android:drawable/btn_star_big_on"
        tools:layout_width="100dp"
        tools:layout_height="100dp"/>
Alexander Suraphel
  • 10,103
  • 10
  • 55
  • 90