Java Android TextView 跑馬燈 不會動 or 時好時壞 筆記

  • 6707
  • 0

摘要:Java Android TextView 跑馬燈 不會動 筆記

01.layout檔view設定

<TextView
                android:id="@+id/map_Address"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:ellipsize="marquee"
                android:focusable="true"
                android:focusableInTouchMode="true"

                android:marqueeRepeatLimit="marquee_forever"
                android:scrollHorizontally="true"
                android:singleLine="true"
                android:text=""
                android:textColor="@color/black"
                android:textSize="@dimen/txtMapPopTitle" />

其中要設置這兩個屬性,讓他可取得focus

android:focusable="true"
android:focusableInTouchMode="true"

 

02.程式中設定textview為選擇狀態


TextView tv = (TextView) this.findViewById(R.id.map_Address);
tv.setSelected(true);