使用 maxLines 选框 [英] Marquee using maxLines

查看:42
本文介绍了使用 maxLines 选框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何使用 MaxLines 而不是 SingleLine 来制作选框?

How can I have a marquee using MaxLines instead of SingleLine ?

这是我的 TextView :

This is my TextView :

<TextView
    android:text="bla bla bla bla bla bla"
    android:id="@+id/MarqueeText" 
    android:layout_width="30dp"
    android:layout_height="wrap_content" 
    android:singleLine="true"
    android:ellipsize="marquee" 
    android:marqueeRepeatLimit="marquee_forever"
    android:scrollHorizontally="true" 
    android:focusable="true" 
    android:focusableInTouchMode="true" 
    android:freezesText="true">

在我的 code.java 之后我 setSelected 我的 TextView :

After in my code.java I setSelected my TextView :

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

问题是 android:singleLine 已被弃用,所以我必须使用 android:maxLines 代替,但选框无法使用它.

The problem is android:singleLine is deprecated so I have to use android:maxLines instead but the marquee don't work with it.

推荐答案

你可以试试这个:

android:maxLength = "10"

设置android:maxLines="1"后,您还必须设置您的inputType.所以,设置你的 android:inputType="text" 就可以了.

After setting android:maxLines="1", you have to set your inputType too. So, set your android:inputType="text" and that should do the trick.

这篇关于使用 maxLines 选框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆