Android的工作室布局previews的列表视图+的GridView视图、布局、工作室、列表

2023-09-06 01:44:11 作者:°年少轻狂放纵不羁爱自由

有没有办法让机器人工作室的布局preVIEW屏幕填充的GridView或ListView与实际运行时的布局占位看法?

Is there a way to get Android Studio's layout preview screen to populate a GridView or ListView with placeholder views of the actual runtime layout?

换句话说,我不希望看到第1项/子项1的意见,我希望能够到的地方设置@布局/ foo和有它出现在那里的网格。

In other words, I don't want to see a grid of "Item 1/ Sub Item 1" views, I want to be able to set @layout/foo somewhere and have it show up in there.

推荐答案

从图形编辑器:

从XML:

<GridView
        xmlns:tools="http://schemas.android.com/tools"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:numColumns="2"
        tools:listitem="@layout/grid_item"/>

注:注意这ISSE: http://stackoverflow.com/a/12188118/624706