在 AWTK中 如何让文本滚动起来

在很多时候,特别是在小屏幕的硬件上,控件比较小而要显示的文本比较长。

此时,我们需要在控件获得焦点时/或点击时,让文本滚动起来,以便让用户看到完整的信息。

AWTK 提供了 hscroll_label_t 控件,可以轻松满足文本滚动的需求。

一、基本用法

示例:

<window anim_hint="htranslate" text="hscroll_label" children_layout="default(c=1,h=30,xm=10,s=5)">
  <hscroll_label text="炫酷的 GUI 引擎。" /> 
  <hscroll_label text="炫酷的 GUI 引擎。" style="right"/> 

  <hscroll_label 
    lull="1000"
    loop="true"
    yoyo="true"
    ellipses="true"
    focusable="true"
    text="(always ellipses loop yoyo) 为用户提供一个功能强大、高效可靠、简单易用、可轻松做出炫酷效果的 GUI 引擎。" /> 

  <hscroll_label 
    focusable="true"
    only_focus="true"
    text="(only_focus noloop) 为用户提供一个功能强大、高效可靠、简单易用、可轻松做出炫酷效果的 GUI 引擎。" /> 

  <hscroll_label 
    loop="true"
    ellipses="true"
    focusable="true"
    only_focus="true"
    text="(only_focus ellipses loop) 为用户提供一个功能强大、高效可靠、简单易用、可轻松做出炫酷效果的 GUI 引擎。" /> 

  <hscroll_label 
    style="green"
    loop="true"
    yoyo="true"
    ellipses="true"
    focusable="true"
    only_focus="true"
    text="(only_focus ellipses loop yoyo) 为用户提供一个功能强大、高效可靠、简单易用、可轻松做出炫酷效果的 GUI 引擎。" /> 

</window>

二、扩展用法

但有时用的不是单纯的文本控件,而是列表项、多选按钮、单选按钮或其它功能的控件,那该怎么办呢?

其实也很简单,把 hscroll_label 作为该控件的子控件,并指定 only_parent_focus 属性为 true 即可。

示例:

<window anim_hint="htranslate" move_focus_prev_key="up" move_focus_next_key="down" text="Basic Controls">
  <row x="0" y="180" w="-50" h="90" children_layout="default(r=1,c=2,m=2)">
    <column children_layout="default(r=3,c=1,ym=2,s=10)" >
      <check_button name="r1" focusable="true" >
        <hscroll_label style="green" only_parent_focus="true" x="right" y="middle" w="-30" h="100%"
          text="1.AWTK 为用户提供一个功能强大、高效可靠、简单易用、可轻松做出炫酷效果的 GUI 引擎。" /> 
      </check_button>

      <check_button name="r2" focusable="true">
        <hscroll_label style="green" only_parent_focus="true" x="right" y="middle" w="-30" h="100%"
          text="2.AWTK 为用户提供一个功能强大、高效可靠、简单易用、可轻松做出炫酷效果的 GUI 引擎。" /> 
      </check_button>

      <check_button name="r3" value="true" focusable="true">
        <hscroll_label style="green" only_parent_focus="true" x="right" y="middle" w="-30" h="100%"
          text="3.AWTK 为用户提供一个功能强大、高效可靠、简单易用、可轻松做出炫酷效果的 GUI 引擎。" /> 
      </check_button>
    </column>
  </row>
</window>
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • 专业考题类型管理运行工作负责人一般作业考题内容选项A选项B选项C选项D选项E选项F正确答案 变电单选GYSZ本规程...
    小白兔去钓鱼阅读 9,049评论 0 13
  • 1、窗体 1、常用属性 (1)Name属性:用来获取或设置窗体的名称,在应用程序中可通过Name属性来引用窗体。 ...
    Moment__格调阅读 4,586评论 0 11
  • ¥开启¥ 【iAPP实现进入界面执行逐一显】 〖2017-08-25 15:22:14〗 《//首先开一个线程,因...
    小菜c阅读 6,497评论 0 17
  • 买了《文案觉醒》一书,感觉很多难题都解开了,这本书对于新手的启发是非常大的,故摘录了这本书的重点,希望能给大家一些...
    星阳JKSUEN阅读 2,775评论 1 3
  • 秋,带着去年离别的不舍,又来到燕鸽湖畔。 对于人们而言,秋是个丰收的季节,带来了累累硕果;对...
    末锋阅读 440评论 1 2