I have a RecyclerView
where each list row item has a CheckBox
. In the layout preview of the list row on its own, the Checkbox is shown correctly, with no text:
However, when I view the layout preview as part of the RecyclerView
(using tools:listitem = "@layout/application_list_content"
), I see unwanted sample texts like "Item 0", "Item 1", "Item 3", and so on:
Question: Is there a way to make Android Studio's Layout Preview not show the sample texts - "Item X" - and instead just display an empty string?
The code for the RecyclerView
is:
<android.support.v7.widget.RecyclerView
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/application_list"
android:name="com.laurivan.android.ApplicationListFragment"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginEnd="?listPreferredItemPaddingRight"
android:layout_marginStart="?listPreferredItemPaddingLeft"
app:layoutManager="LinearLayoutManager"
tools:context="com.laurivan.android.ApplicationListActivity"
tools:listitem="@layout/application_list_content"/>
The item row has something like this:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="wrap_content"
android:layout_height="@dimen/list_item_height_normal"
android:orientation="horizontal"
>
<CheckBox
android:id="@+id/app_checkBox"
style="?android:attr/starStyle"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_alignParentEnd="true"
android:layout_margin="0dp"
android:checked="false"
android:padding="0dp"
tools:text=""
/>
</RelativeLayout>
A RecyclerView.LayoutManager implementation that lays out items in a grid for leanback VerticalGridView and HorizontalGridView . LinearLayoutManager. A RecyclerView.LayoutManager implementation which provides similar functionality to ListView .
In case this helps anyone else, I resorted to using a zero-width whitespace character to do this, i.e. tools:text="​"
in the layout of the Checkbox:
<CheckBox
android:id="@+id/app_checkBox"
style="?android:attr/starStyle"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_alignParentEnd="true"
android:layout_margin="0dp"
android:checked="false"
android:padding="0dp"
tools:text="​"
/>
More info: https://en.wikipedia.org/wiki/Zero-width_space
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With