Android, RelativeLayout restarts Marquee-TextView when changing ImageView in same RelativeLayout

后端 未结 4 1225
星月不相逢
星月不相逢 2021-01-18 20:29

I have not found a solution for my problem, maybe you can help me here.

I am using a RelativeLayout with an ImageView and a TextView as children. The TextView contai

4条回答
  •  陌清茗
    陌清茗 (楼主)
    2021-01-18 20:57

    The marquee reset problem is because of loss of focus of the TextView on which it is running. To overcome these issues you can simply surround your TextView with another RelativeLayout so that it is in a different ViewGroup as your other views.

    You have another option: Create a new class that is a subclass of TextView and override onFocusChanged and onWindowFocusChanged to prevent loss of focus for the said textview.

    That's it. Using these techniques your marquee won't restart every time another element gains focus.

提交回复
热议问题