【Androrid笔记】Listview中的TextView跑马灯显示超长文字

参考链接

https://www.jianshu.com/p/d9001ee71db0

1、listView中一定要加上android:focusable="true"

        <ListView
            android:id="@+id/lv_bills"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:padding="3dp"
            android:focusable="true"
            />


2、对应的listView的item_layout切记千万不要在TextView中加上android:focusable="true"

        <TextView
            android:id="@+id/tv_start_add"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_weight="5"
            android:gravity="center|left"
            android:textSize="16sp"
            android:singleLine="true"
            android:ellipsize="marquee"
            android:marqueeRepeatLimit="marquee_forever"
            />

3、在代码adapter中,要滚动textview添加setSelected(true)

            TextView tv_start_add = (TextView) convertView.findViewById(R.id.tv_start_add);
            tv_start_add.setText(billTmp.startAdd);
            //logWaybill.log2File_Screem(tag, "高度=" + tv_start_add.getHeight()+",测量高度="+tv_start_add.getMeasuredHeight());
            tv_start_add.setSelected(true);












猜你喜欢

转载自blog.csdn.net/mashang123456789/article/details/79353591
今日推荐