title: Does Android TextView support state_pressed state?
body: <p>The real quest is to have a custom ButtonBar(as below) in Android with TextViews acts as buttons and each should reflect their state, pressed/selected.</p>
  <p><a href="https://i.stack.imgur.com/nC620.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/nC620.png" alt="enter image description here" /></a></p>
  <p>The TextView is set with the following background for different states to reflect. What all states supported by Android TextView? Say e.g., if it supports states like pressed/selected, how to update the TextView from XML/Code?</p>
  <pre><code>&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;
  &lt;selector xmlns:android=&quot;http://schemas.android.com/apk/res/android&quot;&gt;
      &lt;item android:state_pressed=&quot;true&quot; android:color=&quot;#ffffff&quot;&gt;
          &lt;shape android:shape=&quot;rectangle&quot;&gt;
              &lt;corners android:radius=&quot;16.5dp&quot; /&gt;
              &lt;size android:width=&quot;168dp&quot; android:height=&quot;34dp&quot; /&gt;
              &lt;solid android:color=&quot;#000000&quot; /&gt;
          &lt;/shape&gt;
      &lt;/item&gt;
      &lt;item android:color=&quot;#000000&quot; &gt;
          &lt;shape android:shape=&quot;rectangle&quot; &gt;
              &lt;corners android:radius=&quot;16.5dp&quot; /&gt;
              &lt;size android:width=&quot;168dp&quot; android:height=&quot;34dp&quot; /&gt;
              &lt;solid android:color=&quot;#FFFFFF&quot; /&gt;
          &lt;/shape&gt;
      &lt;/item&gt;
  &lt;/selector&gt;
  </code></pre>
  <p>TextView code snippet below for reference</p>
  <pre class="lang-xml prettyprint-override"><code>        &lt;TextView
              android:id=&quot;@+id/tv1&quot;
              android:layout_width=&quot;0dp&quot;
              android:layout_height=&quot;40dp&quot;
              android:background=&quot;@drawable/tv_background&quot;
              android:gravity=&quot;center&quot;
              android:maxLines=&quot;1&quot;
              android:onClick=&quot;@{() -&gt; viewModel.onTvClicked()}&quot;
              android:text=&quot;@string/TVTEXT&quot;
              android:textSize=&quot;16sp&quot;
              app:layout_constraintBaseline_toBaselineOf=&quot;@+id/something&quot;
              app:layout_constraintEnd_toStartOf=&quot;@+id/otherthing&quot;
              app:layout_constraintStart_toStartOf=&quot;parent&quot; /&gt;
  
  </code></pre>
  <p>Thanks for your time :)</p>