问题描述:

So I have a TextView with a marquee scroll effect and a simple EditText. Everything works fine until you click on EditText and marquee effect is reset. The question is: how to make the marquee effect infinite and never reset. Code below.

P.S. I have read literally all the questions related to TextView's marquee and nothing works. I have tried custom marquee animations for TextView but, to be honest, android's marquee is the best one. Except the fact, that it is buggy and unmaintained.

XML:

<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"

android:layout_width="match_parent"

android:layout_height="match_parent"

>

<com.example.admin.auctionone.Design.AlwaysMarqueeText

android:layout_width="200dp"

android:layout_height="50dp"

android:layout_marginTop="300dp"

android:id="@+id/am"/>

<EditText

android:layout_width="match_parent"

android:layout_height="50dp"

android:layout_marginTop="400dp"

/>

</FrameLayout>

Code:

 @Override

public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {

super.onViewCreated(view, savedInstanceState);

TextView am = (TextView ) view.findViewById(R.id.am);

am.setText("Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nullam dignissim felis mauris, quis tempus lectus congue nec. Sed id lobortis massa. Suspendisse tempus mollis neque non efficitur. Mauris congue vulputate nunc, in commodo lacus semper eget. Sed vel elementum purus, nec ullamcorper elit. Pellentesque malesuada justo sed neque aliquam varius. Etiam gravida felis in nibh dictum pulvinar. Sed suscipit non augue nec pharetra.");

am.setSingleLine(true);

am.setEllipsize(TextUtils.TruncateAt.MARQUEE);

am.setMarqueeRepeatLimit(-1);

am.setSelected(true);

}

相关阅读:
Top