【问题标题】:Translate TextView from Right to Left将 TextView 从右向左翻译
【发布时间】:2014-10-10 15:02:56
【问题描述】:

在操作栏中有一个 textView。我翻译了textview,但是文本太长而且被剪切或者有点。 我能怎么做?谢谢

这是xml:

<TextView 
    android:id="@+id/current_team_actionbar"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:text="text text text text text text text text text text 5"
    android:textColor="#ffff"
    android:maxLines='1'
    android:textSize="12sp"
    android:alpha="0.5" />

LayoutInflater inflater = LayoutInflater.from(this);
View custom = inflater.inflate(R.layout.layout_custom_actionbar, null);
TextView currentTeam = (TextView) custom.findViewById(R.id.current_team_actionbar);

currentTeam.setText("text text text text text text text text");
actionBarTabsMenu.setCustomView(custom);
actionBarTabsMenu.setDisplayShowCustomEnabled(true);

【问题讨论】:

  • 要么设置较小的文本大小,要么使用 ellipsize="end" 这样你的文本就不会被剪切
  • 您的翻译动画 xml/代码在哪里?
  • Usig ellipsize="end" 有3个点
  • 是的,这是预期的结果。你能做的不多了。文字与您的屏幕尺寸重叠。
  • 除非你想要一个多行的标题

标签: android textview translate-animation


【解决方案1】:

您可能想要的是让文本滚动以使其全部可见:

<TextView
    android:layout_marginLeft="20dp"
    android:layout_marginRight="20dp"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:singleLine="true"
    android:ellipsize="marquee"
    android:marqueeRepeatLimit="marquee_forever"
    android:scrollHorizontally="true"
    android:focusable="true"
    android:focusableInTouchMode="true"/>

【讨论】:

  • @Deca 我忘了您需要添加focusableandroid:focusableInTouchMode 属性,请参阅更新后的答案。
猜你喜欢
  • 2021-01-26
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2018-04-03
  • 1970-01-01
  • 2015-10-31
  • 2017-05-28
  • 2012-09-12
相关资源
最近更新 更多