【问题标题】:android:ellipsize="marquee" not working [duplicate]android:ellipsize =“marquee”不工作[重复]
【发布时间】:2018-05-07 06:17:18
【问题描述】:

我尝试过使用marquee但它不起作用,请帮助解决这个问题

<TextView
            android:id="@+id/text_from"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:ellipsize="marquee"
            android:fadingEdge="horizontal"
            android:singleLine="true"
            android:textColor="#343d43"
            android:textSize="18sp"
            android:textStyle="bold"
            app:layout_constraintEnd_toStartOf="@id/text_to"
            app:layout_constraintStart_toStartOf="@id/label_from"
            app:layout_constraintTop_toBottomOf="@id/label_from" />

【问题讨论】:

    标签: android android-layout android-studio textview marquee


    【解决方案1】:

    android:singleLine弃用。使用

    android:maxLines="1"
    android:focusable="true"
    

    仅供参考

    你应该添加setSelected

    更改此视图的选择状态。可以选择视图或 不是。请注意,选择与焦点不同。

    TextView text_fromOBJ=(TextView) findViewById(R.id.text_from);
    text_fromOBJ.setSelected(true);
    

    【讨论】:

    • 先生,他还需要添加这个textView.setSelected(true)
    • @NileshRathod 是的先生。
    • tnx 添加textView.setSelected(true)就解决了
    • @GautamSurani 确实如此。对于好的方法,请删除 android:singleLine
    【解决方案2】:
    android:focusable="true"
    android:focusableInTouchMode="true"
    

    你需要在java中添加这行

    TextView txtView=(TextView) findViewById(R.id.text_from);
    txtView.setSelected(true);
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-07-25
      • 2015-04-21
      • 2017-12-12
      • 2012-11-15
      • 2018-03-29
      相关资源
      最近更新 更多