Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>As has been mentioned, the <code>borderlessButtonStyle</code> built into the default themes on API11 and above is the simplest way to achieve this effect. You mentioned you are creating your buttons in Java code instead of XML, so there are two options depending on how you need to apply the style.</p> <p><strong>Option #1: Add it to the theme</strong></p> <p>If all the <code>Button</code> or <code>ImageButton</code> instances in your application (or at least within the Activity) need to have this style applied, add the styling to your theme instead:</p> <pre><code>&lt;resources&gt; &lt;style name="AppTheme" parent="android:Theme.Holo.Light"&gt; &lt;!-- Default style for ImageButtons --&gt; &lt;item name="android:imageButtonStyle"&gt;?android:borderlessButtonStyle&lt;/item&gt; &lt;!-- Default style for Buttons --&gt; &lt;item name="android:buttonStyle"&gt;?android:borderlessButtonStyle&lt;/item&gt; &lt;/style&gt; &lt;/resources&gt; </code></pre> <p>With this theme applied to your Application or Activity, you won't have to declare the style of each element, you can just declare them as</p> <pre><code>Button button = new Button(context); ImageButton imageButton = new ImageButton(context); </code></pre> <p>And the styling will be pulled from the theme.</p> <p><strong>Option #2: Declare it in the constructor</strong></p> <p>If only a couple buttons need to be styled this way, you can pass the style attribute you want to apply directly to each view, like so:</p> <pre><code>Button button = new Button(context, null, android.R.attr.borderlessButtonStyle); ImageButton imageButton = new ImageButton(context, null, android.R.attr.borderlessButtonStyle); </code></pre> <p>This version supplies a different default style attribute for the widget to use.</p>
    singulars
    1. This table or related slice is empty.
    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