Google uses AI technology to translate content into your preferred language. AI translations can contain errors.
新增文字字串變化版本
透過集合功能整理內容
你可以依據偏好儲存及分類內容。
不同大小的車輛螢幕可能會顯示不同量的文字。使用 Car App API 級別 2 以上版本時,您可以指定多個文字字串變體,以最符合螢幕的顯示方式呈現。如要查看接受文字變體的範本和元件,請尋找採用 CarText 的範本和元件。
您可以使用 CarText.Builder.addVariant() 方法,將文字字串變體新增至 CarText:
val itemTitle = CarText.Builder("This is a very long string")
.addVariant("Shorter string")
.build()
接著,您可以使用這個 CarText,例如做為 GridItem 的主要文字。
val gridItem = GridItem.Builder()
.setTitle(itemTitle)
.setImage(CarIcon.APP_ICON)
.build()
依偏好程度從高到低新增字串。例如從最長到最短。主機會根據車輛螢幕上的可用空間,選擇適當長度的字串。
這個頁面中的內容和程式碼範例均受《內容授權》中的授權所規範。Java 與 OpenJDK 是 Oracle 和/或其關係企業的商標或註冊商標。
上次更新時間:2026-06-29 (世界標準時間)。
[[["容易理解","easyToUnderstand","thumb-up"],["確實解決了我的問題","solvedMyProblem","thumb-up"],["其他","otherUp","thumb-up"]],[["缺少我需要的資訊","missingTheInformationINeed","thumb-down"],["過於複雜/步驟過多","tooComplicatedTooManySteps","thumb-down"],["過時","outOfDate","thumb-down"],["翻譯問題","translationIssue","thumb-down"],["示例/程式碼問題","samplesCodeIssue","thumb-down"],["其他","otherDown","thumb-down"]],["上次更新時間:2026-06-29 (世界標準時間)。"],[],[]]