首先是依赖地址:implementation 'com.gongwen:marqueelibrary:1.1.3'
项目中遇到要写一个跑马灯的需求,由于功能很简单也不想浪费时间自己写一个,所以百度了一番发现大多数人都是使用的marqueelibrary,按照文档步骤简单的实现了下,以为就可以一次搞定。但最后在使用中发现老是报
java.lang.ClassCastException: android.widget.LinearLayout cannot be cast to android.widget.TextView
xml布局:
<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="horizontal"> <LinearLayout android:layout_width="match_parent" android:layout_height="@dimen/dp_35" android:gravity="center"> <TextView android:id="@+id/content_tv" android:layout_wid