• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2025 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 package com.android.wm.shell.windowdecor
17 
18 import android.content.Context
19 import android.util.AttributeSet
20 import android.widget.TextView
21 
22 /** A custom [TextView] that allows better control over marquee animation used to ellipsize text. */
23 class MarqueedTextView @JvmOverloads constructor(
24     context: Context,
25     attrs: AttributeSet? = null,
26     defStyleAttr: Int = android.R.attr.textViewStyle
27 ) : TextView(context, attrs, defStyleAttr) {
28 
29     /**
30      * Starts marquee animation if the layout attributes for this object include
31      * `android:ellipsize=marquee`, `android:singleLine=true`, and
32      * `android:scrollHorizontally=true`.
33      */
startMarqueenull34     override public fun startMarquee() {
35         super.startMarquee()
36     }
37 
38     /**
39      * Must always return [true] since [TextView.startMarquee()] requires view to be selected or
40      * focused in order to start the marquee animation.
41      *
42      * We are not using [TextView.setSelected()] as this would dispatch undesired accessibility
43      * events.
44      */
isSelectednull45     override fun isSelected() : Boolean {
46         return true
47     }
48 }
49