Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to make android:background="?android:attr/selectableItemBackground work in API level 8

Tags:

android

I have a button code, where in i dont want border for this button, so for that i set propertie "android:background="?android:attr/selectableItemBackground", but it will not work in API version 8 i.e in Froyo emulator. Please provide me the alternatives.

<Button
    android:id="@+id/serviceContactNumber"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:layout_alignBottom="@+id/icon"
    android:layout_alignLeft="@+id/serviceName"
    android:gravity="center_vertical"
    android:singleLine="true"
    android:ellipsize="marquee" 
    android:marqueeRepeatLimit="marquee_forever"
    android:scrollHorizontally="true" 
    android:freezesText="true"
    android:textSize="30dip" 
    android:background="?android:attr/selectableItemBackground"/>

Thanks in advance.

like image 352
Naruto Avatar asked Jul 08 '12 04:07

Naruto


1 Answers

Borderless buttons are part of the Holo theme which is not available to earlier API versions by default. You can however use HoloEverywhere to make the theme available. At this time it does not actually support borderless buttons either but you can get the same effect by setting the buttons background to android:background="@drawable/list_selector_holo_light"

if thats too heavyweight a solution either extract the appropriate assets from holoeverywhere or from \android-sdk\platforms\android-16\data\res\drawable and put them into your own project

like image 144
Chris.D Avatar answered Oct 08 '22 20:10

Chris.D