as.android.com/tools"
3 android:layout_width="match_parent"
4 android:layout_height="match_parent"
5 android:paddingBottom="@dimen/activity_vertical_margin"
6 android:paddingLeft="@dimen/activity_horizontal_margin"
7 android:paddingRight="@dimen/activity_horizontal_margin"
8 android:paddingTop="@dimen/activity_vertical_margin"
9 tools:context=".MainActivity" >
10
11 <com.example.marqueetextview.MarqueeText
12 android:id="@+id/textview1"
13 android:layout_width="wrap_content"
14 android:layout_height="wrap_content"
15 android:ellipsize="marquee"
16 android:focusable="true"
17 android:focusableInTouchMode="true"
18 android:singleLine="true"
19 android:text="@string/hello_world" />
20
21 <com.example.marqueetextview.MarqueeText
22 android:layout_width="wrap_content"
23 android:layout_height="wrap_content"
24 android:layout_below="@id/textview1"
25 android:layout_marginTop="20dp"
26 android:ellipsize="marquee"
27 android:focusable="true"
28 android:focusableInTouchMode="true"
29 android:singleLine="true"
30 android:text="@string/hello_world" />
31
32 </RelativeLayout>
然后我们再看一下效果。
已经全部实现成功了。
那这到底是为什么呢? 奥秘就在我们重载的isFocused()这个函数. return true全部强制Focused.都有焦点了,就都能实现了
如果没设置,焦点都第一个,第二个就无法实现。
这个是我写的Demo:https://pan.baidu.com/s/1M1TghCh_R3kFnReM4li1VQ
|