Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Why don't you just use a button as a button?</p> <p>Just style the button in your attrs.xml. Example:</p> <pre><code>&lt;style name="MyButton.Standard" parent="@android:style/Widget.Button"&gt; &lt;item name="android:textColor"&gt;#FFFFFF&lt;/item&gt; &lt;item name="android:textStyle"&gt;bold&lt;/item&gt; &lt;item name="android:background"&gt;@drawable/btn_gfx&lt;/item&gt; &lt;item name="android:focusable"&gt;true&lt;/item&gt; &lt;item name="android:clickable"&gt;true&lt;/item&gt; &lt;/style&gt; </code></pre> <p>To use this, simply apply the Style to your button in your layout:</p> <pre><code>style="@style/MyButton.Standard" </code></pre> <p>btn_gfx.xml is a StateList drawable</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;selector xmlns:android="http://schemas.android.com/apk/res/android" &gt; &lt;item android:state_pressed="true" android:state_enabled="false" android:drawable="@drawable/btn_tab_pressed_disabled" /&gt; &lt;item android:state_pressed="true" android:state_enabled="true" android:drawable="@drawable/btn_tab_pressed" /&gt; &lt;item android:state_enabled="false" android:drawable="@drawable/btn_tab_disabled" /&gt; &lt;item android:state_enabled="true" android:drawable="@drawable/btn_tab_default" /&gt; &lt;/selector&gt; </code></pre> <p>You can add graphics for even more states, if required - check the Android documentation.</p> <p>If you want to use the same system for button everywhere in your app instead of applying a style on each, you can create a custom theme. An example (without the TitleBar):</p> <pre><code>&lt;style name="MyTheme" parent="@android:style/Theme.NoTitleBar"&gt; &lt;item name="android:buttonStyle"&gt;@style/MyButton.Standard&lt;/item&gt; &lt;/style&gt; </code></pre> <p>Then simply apply the Theme to your Application object (or - if you just want it for a single Activity, apply it to your Activity).</p> <p>You can style the ImageButton component in exactly the same way as the Button component. It's an incredibly powerful system when you start to play around with it.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload