直线列表修改为居中显示 3153/1 3153/head 3154/target/1
authorluozheng <1732036298@qq.com>
Thu, 29 Jan 2026 11:05:13 +0000 (19:05 +0800)
committerluozheng <1732036298@qq.com>
Thu, 29 Jan 2026 11:05:13 +0000 (19:05 +0800)
code/sdk/application/wearable/fd272/nativeapp/nativeui/applist/include/ApplistView.h
code/sdk/application/wearable/fd272/nativeapp/nativeui/applist/src/ApplistView.cpp

index 5466962..fbe463b 100644 (file)
@@ -126,6 +126,7 @@ public:
 private:
     /* for list style */
     void ListStyleOnStart();
+    void ListStyleOnSetUpView();
     void ListStyleOnStop();
     ApplistAdapter *listAdapter_{nullptr};
     UIList *contentList_{nullptr};
index b927257..d36c98c 100644 (file)
@@ -897,6 +897,37 @@ void ApplistView::ListStyleOnStart()
     AddViewToRootContainer(contentList_);
 }
 
+void ApplistView::ListStyleOnSetUpView(void)
+{
+    WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "ApplistView::ListStyleOnSetUpView [%d]", __LINE__);
+    uint16_t startIndex = 0;
+        int16_t headY = 0;
+        if (presenter_->GetStartIndex() >= presenter_->GetListItemNum()) {
+            startIndex = presenter_->GetListItemNum() - 1;
+            headY = VERTICAL_RESOLUTION / NUM_2;
+        } else {
+            uint16_t presliceId = NativeAbility::GetInstance().GetPreSliceId();
+            if (presliceId == VIEW_MAIN) //如果是从主页进入的,那么startIndex = 0,headY = 0
+            {
+                startIndex = 0;
+                headY = 68;
+            } else { //如果是从其他页面进入的,那么startIndex = presenter_->GetArcListStartIndex(),headY = presenter_->GetArcListHeadItemY()
+                startIndex = presenter_->GetArcListStartIndex();
+                headY = presenter_->GetArcListHeadItemY();
+            }
+            if (headY == 0) { 
+                headY = VERTICAL_RESOLUTION / NUM_2;
+            }
+        }
+        WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "startIndex = %d, headY = %d\n", startIndex, headY);
+        contentList_->SetAdapter(listAdapter_);
+        contentList_->ScrollTo(startIndex);
+        contentList_->ScrollBy(headY);
+        contentList_->RefreshList();
+    return;
+}
+
+
 void ApplistView::ResumeWaterFallDraggable()
 {
     if (waterfallList_ != nullptr) {
@@ -1058,23 +1089,8 @@ void ApplistView::RefreshAppList(void)
         ArcScaleListStyleOnSetUpView();
     } else if (style == AppListStyle::CIRCLE_LIST_STYLE) {
         // 拨号盘
-    } else {
-        uint16_t startIndex = 0;
-        int16_t headY = 0;
-        if (presenter_->GetStartIndex() >= presenter_->GetListItemNum()) {
-            startIndex = presenter_->GetListItemNum() - 1;
-            headY = VERTICAL_RESOLUTION / NUM_2;
-        } else {
-            startIndex = presenter_->GetStartIndex();
-            headY = presenter_->GetHeadItemY();
-            if (headY == 0) {
-                headY = VERTICAL_RESOLUTION / NUM_2;
-            }
-        }
-        contentList_->SetAdapter(listAdapter_);
-        contentList_->ScrollTo(startIndex);
-        contentList_->ScrollBy(headY);
-        contentList_->RefreshList();
+    } else if (style == AppListStyle::APPLIST_STYLE) {
+        ListStyleOnSetUpView();
     }
 }