[English]

Tile view(平铺视图) (lv_tileview)

Overview(概述)

显示原文

The Tile view is a container object whose elements (called tiles) can be arranged in grid form. A user can navigate between the tiles by swiping. Any direction of swiping can be disabled on the tiles individually to not allow moving from one tile to another.

If the Tile view is screen sized, the user interface resembles what you may have seen on smartwatches.


平铺视图(Tileview)是一个容器对象,其中的元素( tiles(瓷砖) )可以以网格形式排列。用户可以通过滑动在瓷砖之间导航。可以单独在瓷砖上禁用任意方向的滑动,以防止从一个瓷砖移动到另一个瓷砖。

如果平铺视图设置为屏幕大小,则用户界面类似于在智能手表上看到的界面。

Parts and Styles(部分和样式)

显示原文

The Tile view is built from an lv_obj.h container and lv_obj.h tiles.

The parts and styles work the same as for lv_obj.h.


平铺视图是由 lv_obj.h 容器和 lv_obj.h 平铺构建而成的。

部分和样式的工作方式与 lv_obj.h 相同。

Usage(用法)

Add a tile(添加瓷砖)

显示原文

lv_tileview_add_tile(tileview, col_id, row_id, dir) creates a new tile on the col_idth column and row_idth row. dir can be LV_DIR_LEFT/RIGHT/TOP/BOTTOM/HOR/VER/ALL or OR-ed values to enable moving to the adjacent tiles into the given direction by swiping.

The returned value is an lv_obj_t * on which the content of the tab can be created.


lv_tileview_add_tile(tileview, row_id, col_id, dir) 函数在平铺视图 tileview 中的第 col_id 列和第 row_id 行创建了一个新的瓷砖。dir 参数可以是 LV_DIR_LEFT/RIGHT/TOP/BOTTOM/HOR/VER/ALL 中的一个或多个值,通过按位或(OR-ed)操作来组合,以允许通过滑动手势在给定方向上移动到相邻的瓷砖。

返回的值是 lv_obj_t * 可以在其(瓷砖)上填充内容。

Change tile(切换瓷砖显示)

显示原文

The Tile view can scroll to a tile with lv_tileview_set_tile(tileview, tile_obj, LV_ANIM_ON / OFF) or lv_tileview_set_tile_by_index(tileview, col_id, row_id, LV_ANIM_ON / OFF)


平铺视图可以使用接口 lv_tileview_set_tile(tileview, tile_obj, LV_ANIM_ON / OFF)lv_tileview_set_tile_by_index(tileview, col_id, row_id, LV_ANIM_ON / OFF) 切换到指定的瓷砖。

Events(事件)

显示原文

Keys(按键)

显示原文

Keys are not handled by the Tile view.

Learn more about Keys(按键).


平铺视图不处理任何 按键

了解有关 Keys(按键) 的更多信息。

Example

[English]

Tileview with content

#include "../../lv_examples.h"
#if LV_USE_TILEVIEW && LV_BUILD_EXAMPLES

/**
 * Create a 2x2 tile view and allow scrolling only in an "L" shape.
 * Demonstrate scroll chaining with a long list that
 * scrolls the tile view when it can't be scrolled further.
 */
void lv_example_tileview_1(void)
{
    lv_obj_t * tv = lv_tileview_create(lv_screen_active());

    /*Tile1: just a label*/
    lv_obj_t * tile1 = lv_tileview_add_tile(tv, 0, 0, LV_DIR_BOTTOM);
    lv_obj_t * label = lv_label_create(tile1);
    lv_label_set_text(label, "Scroll down");
    lv_obj_center(label);

    /*Tile2: a button*/
    lv_obj_t * tile2 = lv_tileview_add_tile(tv, 0, 1, LV_DIR_TOP | LV_DIR_RIGHT);

    lv_obj_t * btn = lv_button_create(tile2);

    label = lv_label_create(btn);
    lv_label_set_text(label, "Scroll up or right");

    lv_obj_set_size(btn, LV_SIZE_CONTENT, LV_SIZE_CONTENT);
    lv_obj_center(btn);

    /*Tile3: a list*/
    lv_obj_t * tile3 = lv_tileview_add_tile(tv, 1, 1, LV_DIR_LEFT);
    lv_obj_t * list = lv_list_create(tile3);
    lv_obj_set_size(list, LV_PCT(100), LV_PCT(100));

    lv_list_add_button(list, NULL, "One");
    lv_list_add_button(list, NULL, "Two");
    lv_list_add_button(list, NULL, "Three");
    lv_list_add_button(list, NULL, "Four");
    lv_list_add_button(list, NULL, "Five");
    lv_list_add_button(list, NULL, "Six");
    lv_list_add_button(list, NULL, "Seven");
    lv_list_add_button(list, NULL, "Eight");
    lv_list_add_button(list, NULL, "Nine");
    lv_list_add_button(list, NULL, "Ten");

}

#endif

API

lv_tileview.h

lv_types.h

lv_api_map_v8.h