Search Results

Search found 708 results on 29 pages for 'drawable'.

Page 1/29 | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >

  • Android : Customizing tabs on state : How do I make a selector a drawable

    - by Chrispix
    I know how to put the icon on each tab, that is no problem. I also ran across this : Stack Overflow thread on pretty much same thing I followed one of the links from that question, and found this Pretty much, it said use a selector defined in the xml, sure, did that. But there is no id associated w/ it so I am not sure how to get the selector function as a drawable so I can use it as the icon for the tabs. Maybe I am going about this the wrong way.. But this is what I have, and obviously missing something. <selector android:id="@+id/myselector" xmlns:android="http://schemas.android.com/apk/res/android"> <!-- Non focused states --> <item android:state_focused="false" android:state_selected="false" android:state_pressed="false" android:drawable="@drawable/darklogo" /> <item android:state_focused="false" android:state_selected="true" android:state_pressed="false" android:drawable="@drawable/lightlogo" /> <!-- Focused states --> <item android:state_focused="true" android:state_selected="false" android:state_pressed="false" android:drawable="@drawable/lightlogo" /> <item android:state_focused="true" android:state_selected="true" android:state_pressed="false" android:drawable="@drawable/lightlogo" /> <!-- Pressed --> <item android:state_pressed="true" android:drawable="@drawable/lightlogo" /> </selector> In my code, an example tab is generated using : host.addTab(host.newTabSpec("three") .setIndicator("map",drawables) .setContent(new Intent(this, Map.class))); Right now drawables is just a reference to an drawable image resource. How do I make the selector a drawable? * This is my question *

    Read the article

  • NinePatchDrawable from Drawable.createFromPath or FileInputStream

    - by Tim H
    I cannot get a nine patch drawable to work (i.e. it is stretching the nine patch image) when loading from either Drawable.createFromPath or from a number of other methods using an InputStream. Loading the same nine patch works fine when loading from when resources. Here's the methods I am trying: Button b = (Button) findViewById(R.id.Button01); Drawable d = null; //From Resources (WORKS!) d = getResources().getDrawable(R.drawable.test); //From Raw Resources (Doesn't Work) InputStream is = getResources().openRawResource(R.raw.test); d = Drawable.createFromStream(is, null); //From Assets (Doesn't Work) try { InputStream is = getResources().getAssets().open("test.9.png"); d = Drawable.createFromStream(is, null); } catch (Exception e) {e.printStackTrace();} //From FileInputStream (Doesn't Work) try { FileInputStream is = openFileInput("test.9.png"); d = Drawable.createFromStream(is, null); } catch (Exception e) {e.printStackTrace();} //From File path (Doesn't Work) d = Drawable.createFromPath(getFilesDir() + "/test.9.png"); if (d != null) b.setBackgroundDrawable(d);

    Read the article

  • Problem with Android emulator

    - by benasio
    Projects do not run, on screen emulator only "ANDROID" WinXP pro SP3/Eclipse Galileo java version "1.6.0_20" Java(TM) SE Runtime Environment (build 1.6.0_20-b02) Java HotSpot(TM) Client VM (build 16.3-b01, mixed mode, sharing) My actions: 1.Start the emulator(Platform:2.1 API Level:7), wait until the window DDMS status will change to ONLINE 2.Launches helloandroid from examples - Run as Android Application Console: Android Launch! [2010-05-03 21:44:34 - HelloAndroid] adb is running normally. [2010-05-03 21:44:34 - HelloAndroid] Performing com.example.helloandroid.HelloAndroid activity launch [2010-05-03 21:44:34 - HelloAndroid] Automatic Target Mode: using existing emulator 'emulator-5554' running compatible AVD 'my_vm' [2010-05-03 21:44:34 - HelloAndroid] WARNING: Application does not specify an API level requirement! [2010-05-03 21:44:34 - HelloAndroid] Device API version is 7 (Android 2.1) [2010-05-03 21:44:34 - HelloAndroid] Uploading HelloAndroid.apk onto device 'emulator-5554' [2010-05-03 21:44:35 - HelloAndroid] Installing HelloAndroid.apk... [2010-05-03 21:45:07 - HelloAndroid] Success! [2010-05-03 21:45:08 - HelloAndroid] Starting activity com.example.helloandroid.HelloAndroid on device [2010-05-03 21:45:28 - HelloAndroid] ActivityManager: DDM dispatch reg wait timeout [2010-05-03 21:45:28 - HelloAndroid] ActivityManager: Can't dispatch DDM chunk 52454151: no handler defined [2010-05-03 21:45:28 - HelloAndroid] ActivityManager: Can't dispatch DDM chunk 48454c4f: no handler defined [2010-05-03 21:45:28 - HelloAndroid] ActivityManager: Can't dispatch DDM chunk 46454154: no handler defined [2010-05-03 21:45:28 - HelloAndroid] ActivityManager: Can't dispatch DDM chunk 4d505251: no handler defined [2010-05-03 21:45:52 - HelloAndroid] Device not ready. Waiting 3 seconds before next attempt. [2010-05-03 21:45:52 - HelloAndroid] ActivityManager: android.util.AndroidException: Can't connect to activity manager; is the system running? [2010-05-03 21:45:55 - HelloAndroid] Starting activity com.example.helloandroid.HelloAndroid on device [2010-05-03 21:46:11 - HelloAndroid] ActivityManager: DDM dispatch reg wait timeout ...... DDMS console (only errors and warnings) 05-03 17:43:52.437: ERROR/vold(26): Error opening switch name path '/sys/class/switch/test2' (No such file or directory) 05-03 17:43:52.437: ERROR/vold(26): Error bootstrapping switch '/sys/class/switch/test2' (No such file or directory) 05-03 17:43:52.437: ERROR/vold(26): Error opening switch name path '/sys/class/switch/test' (No such file or directory) 05-03 17:43:52.437: ERROR/vold(26): Error bootstrapping switch '/sys/class/switch/test' (No such file or directory) 05-03 17:48:34.036: WARN/Zygote(29): Preloaded drawable resource #0x1080093 (res/drawable-mdpi/sym_def_app_icon.png) that varies with configuration!! 05-03 17:48:34.406: WARN/Zygote(29): Preloaded drawable resource #0x1080002 (res/drawable-mdpi/arrow_down_float.png) that varies with configuration!! 05-03 17:48:35.836: WARN/Zygote(29): Preloaded drawable resource #0x10800b4 (res/drawable/btn_check.xml) that varies with configuration!! 05-03 17:48:36.076: WARN/Zygote(29): Preloaded drawable resource #0x10800b7 (res/drawable-mdpi/btn_check_label_background.9.png) that varies with configuration!! 05-03 17:48:36.106: WARN/Zygote(29): Preloaded drawable resource #0x10800b8 (res/drawable-mdpi/btn_check_off.png) that varies with configuration!! 05-03 17:48:36.147: WARN/Zygote(29): Preloaded drawable resource #0x10800bd (res/drawable-mdpi/btn_check_on.png) that varies with configuration!! 05-03 17:48:36.437: WARN/Zygote(29): Preloaded drawable resource #0x1080004 (res/drawable/btn_default.xml) that varies with configuration!! 05-03 17:48:36.716: WARN/Zygote(29): Preloaded drawable resource #0x1080005 (res/drawable/btn_default_small.xml) that varies with configuration!! 05-03 17:48:36.966: WARN/Zygote(29): Preloaded drawable resource #0x1080006 (res/drawable/btn_dropdown.xml) that varies with configuration!! 05-03 17:48:37.326: WARN/Zygote(29): Preloaded drawable resource #0x1080008 (res/drawable/btn_plus.xml) that varies with configuration!! 05-03 17:48:37.707: WARN/Zygote(29): Preloaded drawable resource #0x1080007 (res/drawable/btn_minus.xml) that varies with configuration!! 05-03 17:48:38.057: WARN/Zygote(29): Preloaded drawable resource #0x1080009 (res/drawable/btn_radio.xml) that varies with configuration!! 05-03 17:48:38.776: WARN/Zygote(29): Preloaded drawable resource #0x108000a (res/drawable/btn_star.xml) that varies with configuration!! 05-03 17:48:39.327: WARN/Zygote(29): Preloaded drawable resource #0x1080125 (res/drawable/btn_toggle.xml) that varies with configuration!! 05-03 17:48:39.416: WARN/Zygote(29): Preloaded drawable resource #0x1080187 (res/drawable-mdpi/ic_emergency.png) that varies with configuration!! 05-03 17:48:39.506: WARN/Zygote(29): Preloaded drawable resource #0x1080012 (res/drawable-mdpi/divider_horizontal_bright.9.png) that varies with configuration!! 05-03 17:48:39.576: WARN/Zygote(29): Preloaded drawable resource #0x1080014 (res/drawable-mdpi/divider_horizontal_dark.9.png) that varies with configuration!! 05-03 17:48:40.126: WARN/Zygote(29): Preloaded drawable resource #0x1080016 (res/drawable/edit_text.xml) that varies with configuration!! 05-03 17:48:40.507: WARN/Zygote(29): Preloaded drawable resource #0x1080161 (res/drawable/expander_group.xml) that varies with configuration!! 05-03 17:48:41.036: WARN/Zygote(29): Preloaded drawable resource #0x1080062 (res/drawable/list_selector_background.xml) that varies with configuration!! 05-03 17:48:41.177: WARN/Zygote(29): Preloaded drawable resource #0x1080217 (res/drawable-mdpi/menu_background.9.png) that varies with configuration!! 05-03 17:48:41.256: WARN/Zygote(29): Preloaded drawable resource #0x1080218 (res/drawable-mdpi/menu_background_fill_parent_width.9.png) that varies with configuration!! 05-03 17:48:41.567: WARN/Zygote(29): Preloaded drawable resource #0x1080219 (res/drawable/menu_selector.xml) that varies with configuration!! 05-03 17:48:41.706: WARN/Zygote(29): Preloaded drawable resource #0x1080224 (res/drawable-mdpi/panel_background.9.png) that varies with configuration!! 05-03 17:48:41.849: WARN/Zygote(29): Preloaded drawable resource #0x108022e (res/drawable-mdpi/popup_bottom_bright.9.png) that varies with configuration!! 05-03 17:48:42.026: WARN/Zygote(29): Preloaded drawable resource #0x108022f (res/drawable-mdpi/popup_bottom_dark.9.png) that varies with configuration!! 05-03 17:48:42.156: WARN/Zygote(29): Preloaded drawable resource #0x1080230 (res/drawable-mdpi/popup_bottom_medium.9.png) that varies with configuration!! 05-03 17:48:42.276: WARN/Zygote(29): Preloaded drawable resource #0x1080231 (res/drawable-mdpi/popup_center_bright.9.png) that varies with configuration!! 05-03 17:48:42.376: WARN/Zygote(29): Preloaded drawable resource #0x1080232 (res/drawable-mdpi/popup_center_dark.9.png) that varies with configuration!! 05-03 17:48:42.507: WARN/Zygote(29): Preloaded drawable resource #0x1080235 (res/drawable-mdpi/popup_full_dark.9.png) that varies with configuration!! 05-03 17:48:42.606: WARN/Zygote(29): Preloaded drawable resource #0x1080238 (res/drawable-mdpi/popup_top_bright.9.png) that varies with configuration!! 05-03 17:48:42.696: WARN/Zygote(29): Preloaded drawable resource #0x1080239 (res/drawable-mdpi/popup_top_dark.9.png) that varies with configuration!! 05-03 17:48:42.946: WARN/Zygote(29): Preloaded drawable resource #0x108006d (res/drawable/progress_indeterminate_horizontal.xml) that varies with configuration!! 05-03 17:48:43.076: WARN/Zygote(29): Preloaded drawable resource #0x108023f (res/drawable/progress_small.xml) that varies with configuration!! 05-03 17:48:43.456: WARN/Zygote(29): Preloaded drawable resource #0x1080240 (res/drawable/progress_small_titlebar.xml) that varies with configuration!! 05-03 17:48:43.957: WARN/Zygote(29): Preloaded drawable resource #0x1080262 (res/drawable-mdpi/scrollbar_handle_horizontal.9.png) that varies with configuration!! 05-03 17:48:44.036: WARN/Zygote(29): Preloaded drawable resource #0x1080263 (res/drawable-mdpi/scrollbar_handle_vertical.9.png) that varies with configuration!! 05-03 17:48:44.176: WARN/Zygote(29): Preloaded drawable resource #0x1080071 (res/drawable/spinner_dropdown_background.xml) that varies with configuration!! 05-03 17:48:44.317: WARN/Zygote(29): Preloaded drawable resource #0x1080326 (res/drawable-mdpi/title_bar_shadow.9.png) that varies with configuration!! 05-03 17:48:44.496: WARN/Zygote(29): Preloaded drawable resource #0x10801c6 (res/drawable-mdpi/indicator_code_lock_drag_direction_green_up.png) that varies with configuration!! 05-03 17:48:44.607: WARN/Zygote(29): Preloaded drawable resource #0x10801c7 (res/drawable-mdpi/indicator_code_lock_drag_direction_red_up.png) that varies with configuration!! 05-03 17:48:45.956: WARN/Zygote(29): Preloaded drawable resource #0x10801c8 (res/drawable-mdpi/indicator_code_lock_point_area_default.png) that varies with configuration!! 05-03 17:48:46.407: WARN/Zygote(29): Preloaded drawable resource #0x10801c9 (res/drawable-mdpi/indicator_code_lock_point_area_green.png) that varies with configuration!! 05-03 17:48:46.696: WARN/Zygote(29): Preloaded drawable resource #0x10801ca (res/drawable-mdpi/indicator_code_lock_point_area_red.png) that varies with configuration!! 05-03 17:48:56.307: ERROR/BatteryService(170): usbOnlinePath not found 05-03 17:48:56.336: ERROR/BatteryService(170): batteryVoltagePath not found 05-03 17:48:56.350: ERROR/BatteryService(170): batteryTemperaturePath not found 05-03 17:48:56.696: ERROR/SurfaceFlinger(170): Couldn't open /sys/power/wait_for_fb_sleep or /sys/power/wait_for_fb_wake 05-03 17:48:57.847: WARN/SurfaceFlinger(170): ro.sf.lcd_density not defined, using 160 dpi by default. 05-03 17:49:02.116: WARN/UsageStats(170): Usage stats version changed; dropping 05-03 17:49:05.036: WARN/zipro(182): Unable to open zip '/data/local/bootanimation.zip': No such file or directory 05-03 17:49:06.297: WARN/zipro(182): Unable to open zip '/system/media/bootanimation.zip': No such file or directory 05-03 17:49:50.637: WARN/PackageManager(170): Running ENG build: no pre-dexopt! 05-03 17:53:59.196: WARN/PackageManager(170): Unknown permission com.google.android.providers.gmail.permission.WRITE_GMAIL in package com.android.settings 05-03 17:53:59.238: WARN/PackageManager(170): Unknown permission com.google.android.providers.gmail.permission.READ_GMAIL in package com.android.settings 05-03 17:53:59.286: WARN/PackageManager(170): Unknown permission com.google.android.googleapps.permission.GOOGLE_AUTH in package com.android.settings 05-03 17:53:59.517: WARN/PackageManager(170): Unknown permission com.google.android.googleapps.permission.GOOGLE_AUTH in package com.android.providers.contacts 05-03 17:53:59.656: WARN/PackageManager(170): Unknown permission com.google.android.googleapps.permission.GOOGLE_AUTH.cp in package com.android.providers.contacts 05-03 17:53:59.717: WARN/PackageManager(170): Unknown permission com.google.android.googleapps.permission.GOOGLE_AUTH.mail in package com.android.contacts 05-03 17:53:59.796: WARN/PackageManager(170): Unknown permission android.permission.ADD_SYSTEM_SERVICE in package com.android.phone 05-03 17:54:00.126: WARN/PackageManager(170): Unknown permission com.google.android.googleapps.permission.GOOGLE_AUTH in package com.android.development 05-03 17:54:00.206: WARN/PackageManager(170): Unknown permission com.google.android.googleapps.permission.GOOGLE_AUTH.ALL_SERVICES in package com.android.development 05-03 17:54:00.206: WARN/PackageManager(170): Unknown permission com.google.android.googleapps.permission.GOOGLE_AUTH.YouTubeUser in package com.android.development 05-03 17:54:00.237: WARN/PackageManager(170): Unknown permission com.google.android.googleapps.permission.ACCESS_GOOGLE_PASSWORD in package com.android.development 05-03 17:54:00.258: WARN/PackageManager(170): Unknown permission com.google.android.googleapps.permission.GOOGLE_AUTH in package com.android.browser 05-03 17:54:25.456: WARN/ResourceType(170): Resources don't contain package for resource number 0x7f0700e5 05-03 17:54:25.486: WARN/ResourceType(170): Resources don't contain package for resource number 0x7f020031 05-03 17:54:25.536: WARN/ResourceType(170): Resources don't contain package for resource number 0x7f020030 05-03 17:54:25.576: WARN/ResourceType(170): Resources don't contain package for resource number 0x7f050000 05-03 17:54:38.708: WARN/SharedBufferStack(182): waitForCondition(LockCondition) timed out (identity=0, status=0). CPU may be pegged. trying again.

    Read the article

  • Android: retrieving all Drawable resources from Resources object

    - by Matt Huggins
    In my Android project, I want to loop through the entire collection of Drawable resources. Normally, you can only retrieve a specific resource via its ID using something like: InputStream is = Resources.getSystem().openRawResource(resourceId) However, I want to get all Drawable resources where I won't know their ID's beforehand. Is there a collection I can loop through or perhaps a way to get the list of resource ID's given the resources in my project? Or, is there a way for me in Java to extract all property values from the R.drawable static class?

    Read the article

  • Android: how to convert a Drawable to Bitmap

    - by Rob
    How can I convert a Drawable to a Bitmap? I would like to set a certain drawable as the device's wallpaper, but all wallpaper functions accept Bitmaps only (I cannot use WallpaperManager - I'm pre 2.1). Also, my drawables are downloaded from the web and do not reside in R.drawable. Thanks, Rob

    Read the article

  • How to draw a Drawable over a View

    - by Palo
    I have several Views in my Activity. I want to draw a Drawable over these views. The Drawable should be on top of the views (that means it hides the views below it. The Drawable may appear over several views (that is I can't just draw it in one view). How can this be done? Thank you

    Read the article

  • Android: changing drawable states of option menu items seems to have side-effects

    - by pjv
    In my onCreateOptionsMenu() I have basically the following: public boolean onCreateOptionsMenu(Menu menu) { menu.add(Menu.NONE, MENU_ITEM_INSERT, Menu.NONE, R.string.item_menu_insert).setShortcut('3', 'a').setIcon(android.R.drawable.ic_menu_add); PackageManager pm = getPackageManager(); if(pm.hasSystemFeature(PackageManager.FEATURE_CAMERA) && pm.hasSystemFeature(PackageManager.FEATURE_CAMERA_AUTOFOCUS)){ menu.add(Menu.NONE, MENU_ITEM_SCAN_ADD, Menu.NONE, ((Collectionista.DEBUG)?"DEBUG Scan and add item":getString(R.string.item_menu_scan_add))).setShortcut('4', 'a').setIcon(android.R.drawable.ic_menu_add); } ... } And in onPrepareOptionsMenu among others the following: final boolean scanAvailable = ScanIntent.isInstalled(this); final MusicCDItemScanAddTask task = new MusicCDItemScanAddTask(this); menu.findItem(MENU_ITEM_SCAN_ADD).setEnabled(scanAvailable && (tasks == null || !existsTask(task))); As you see, two options items have the same drawable set (android.R.drawable.ic_menu_add). Now, if in onPrepareOptionsMenu the second menu item gets disabled, its label and icon become gray, but also the icon of the first menu item becomes gray, while the label of that fist menu item stays black and it remains clickable. What is causing this crosstalk between the two icons/drawables? Shouldn't the system handle things like mutate() in this case? I've included a screenshot:

    Read the article

  • How can I set drawable to a ListView in android

    - by sxingfeng
    I am writing a app for android 1.5. I want to use a complex listview to display my data. I want to show a ImageView of a drawable object in my List item. I learned from a demo: ------> listData.put("Img", listData.put("Img", R.drawable.XXX)); listData.put("Time", "100"); listItems.add(listData); It can display correctly, however, I want to change Img at runtime, The image maybe generated at run-time, so I change the code as follow, but it falls. Can anyone help me ? many thanks! protected void onCreate(Bundle savedInstanceState) { // TODO Auto-generated method stub super.onCreate(savedInstanceState); setContentView(R.layout.item_list); itemListView = (ListView) findViewById(R.id.listview); ArrayList<HashMap<String, Object>> listItems = new ArrayList<HashMap<String, Object>>(); for(int i = 0;i <XXX.size(); ++i) { HashMap<String, Object> listData = new HashMap<String, Object>(); ---------> 1) listData.put("Img", new Drawable(XXX)); 2) listData.put("Time", "100"); 3) listItems.add(listData); } SimpleAdapter listItemAdapter = new SimpleAdapter(this, listItems, R.layout.listitem, new String[] { "Img", "Time"}, new int[] { R.id.listitem_img, R.id.listitem_time }); itemListView.setAdapter(listItemAdapter); listitem.xml <?xml version="1.0" encoding="utf-8"?> <LinearLayout android:layout_width="fill_parent" xmlns:android="http://schemas.android.com/apk/res/android" android:layout_height="wrap_content" android:paddingBottom="4dip" android:paddingLeft="12dip" android:paddingRight="12dip"> <ImageView android:paddingTop="12dip" android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/listitem_img" /> <TextView android:layout_height="wrap_content" android:textSize="20dip" android:layout_width="wrap_content" android:id="@+id/listitem_time" /> </LinearLayout>

    Read the article

  • Display a gallery of images that are stored as Drawables in a List

    - by Tyler
    Hello - I am trying to modify this example: http://developer.android.com/resources/tutorials/views/hello-gridview.html But instead of displaying images that are resources, I want to display Drawables that I currently am storing in a List. Can anyone instruct me on how I would modify private Integer[] mThumbIds = { R.drawable.sample_2, R.drawable.sample_3, R.drawable.sample_4, R.drawable.sample_5, R.drawable.sample_6, R.drawable.sample_7, R.drawable.sample_0, R.drawable.sample_1, R.drawable.sample_2, R.drawable.sample_3, R.drawable.sample_4, R.drawable.sample_5, R.drawable.sample_6, R.drawable.sample_7, R.drawable.sample_0, R.drawable.sample_1, R.drawable.sample_2, R.drawable.sample_3, R.drawable.sample_4, R.drawable.sample_5, R.drawable.sample_6, R.drawable.sample_7 }; To display my drawable items instead? Thanks!

    Read the article

  • Dispaly a gallery of images that are stored as Drawables in a List

    - by Tyler
    Hello - I am trying to modify this example: http://developer.android.com/resources/tutorials/views/hello-gridview.html But instead of displaying images that are resources, I want to display Drawables that I currently am storing in a List. Can anyone instruct me on how I would modify private Integer[] mThumbIds = { R.drawable.sample_2, R.drawable.sample_3, R.drawable.sample_4, R.drawable.sample_5, R.drawable.sample_6, R.drawable.sample_7, R.drawable.sample_0, R.drawable.sample_1, R.drawable.sample_2, R.drawable.sample_3, R.drawable.sample_4, R.drawable.sample_5, R.drawable.sample_6, R.drawable.sample_7, R.drawable.sample_0, R.drawable.sample_1, R.drawable.sample_2, R.drawable.sample_3, R.drawable.sample_4, R.drawable.sample_5, R.drawable.sample_6, R.drawable.sample_7 }; To display my drawable items instead? Thanks!

    Read the article

  • Drawable advantage over bitmap for memory in android

    - by Tabish
    This question is linked with the answers in the following question: Error removing Bitmaps[Android] Is there any advantage of using Drawable over Bitmap in Android in terms of memory de-allocation ? I was looking at Romain Guy project Shelves and he uses SoftReference for images caches but I'm unable to search where is the code which is de-allocating these Drawables when SoftReference automatically reclaims the memory for Bitmap. As far as I know .recycle() has to be explicitly called on the Bitmap for it to be de-allocated.

    Read the article

  • Masking a Drawable/Bitmap on Android

    - by Joshua Rodgers
    I'm currently looking for a way to use a black and white bitmap to mask the alpha channel of another bitmap or Drawable on Android. I'm curious as to what the best way to do this is. I certainly have a couple of ideas for how to do this, but they are not optimal. I need to be able to apply a new mask to the image every so often (the black and white bitmap will change every few seconds). Any feedback on how to achieve this would be greatly appreciated.

    Read the article

  • Android: Where to find the RadioButton Drawable?

    - by Peterdk
    Ok, I am trying to create a custom view called CheckedRelativeLayout. It's purpose is the same as a CheckedTextView, to be able to use it in a list of items you want selected or in a Spinner. It's all working fine now, I extended RelativeLayout and implemented Checkable interface. However, I am stuck on a quite simple problem: Where can I find the Drawable that CheckedTextView and RadioButton use? I looked at the sourcecode of both, and they seem to use com.android.internal.R. Well... that's internal stuff. So I can't access it. Any way to get these Drawables or solve the problem somehow?

    Read the article

  • How do I set the rounded corner radius of a color drawable using xml?

    - by Jay Askren
    On the android website, there is a section about color drawables. Defining these drawables in xml looks like this: <resources> <drawable name="solid_red">#f00</drawable> <drawable name="solid_blue">#0000ff</drawable> <drawable name="solid_green">#f0f0</drawable> </resources> In the java api, they have thr following method to define rounded corners: setCornerRadius(float radius) Is there a way to set the rounded corners in the xml?

    Read the article

  • Apply an Animation on a Drawable in Android

    - by Casebash
    I am adding a glow animation effect to a logo. So far, I have managed to get the glow image behind the logo, using a LayeredDrawable, but I can't figure out how to animate it. I have found that AlphaAnimation would achieve the desired effect, but unfortunately I can only apply it on Views, not Drawables. How can I achieve this effect?

    Read the article

  • How can I reference a drawable class in Android XML

    - by James Veenstra
    I've created a class that extends drawable that I'd like to reference inside a resource xml. I happen to need it in a selector, like so: <selector xmlns:android="http://schemas.android.com/apk/res/android"> <item android:state_window_focused="false" android:state_pressed="false" android:drawable="com.sample.android.contacts.TopBarCollapsed" /> <item android:state_window_focused="true" android:state_pressed="true" android:drawable="@drawable/top_switcher_collapsed_selected" /> <item android:state_focused="true" android:drawable="@drawable/top_switcher_collapsed_focused" /> com.sample.android.contacts.TopBarCollapsed is the class that extends drawable.

    Read the article

  • Android beginner: Touch events in android gridview

    - by jja
    I am using the following code to do things with gridview(slightly modified from http://developer.android.com/resources/tutorials/views/hello-gridview.html). I want to replace the onClicklistener and the onClick() method with their "touch" equivalents i.e. touchlistener and onTouch() so that when i touch an element in the gridview the image of the element changes and a double touch on the same element takes it back to the orginal state. How do I do this? I can't get my code to do this. The clicklistener works to some extent but the touch isn't. Please help. public class ImageAdapter extends BaseAdapter { private Context mContext; public ImageAdapter(Context c) { mContext = c; } public int getCount() { return mThumbIds.length; } public Object getItem(int position) { return null; } public long getItemId(int position) { return 0; } // create a new ImageView for each item referenced by the Adapter public View getView(int position, View convertView, ViewGroup parent) { ImageView imageView; if (convertView == null) { // if it's not recycled, initialize some attributes imageView = new ImageView(mContext); imageView.setLayoutParams(new GridView.LayoutParams(85, 85)); imageView.setScaleType(ImageView.ScaleType.CENTER_CROP); imageView.setPadding(8, 8, 8, 8); imageView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { if(position==0) { //do this } else { //do this } } }); } else { imageView = (ImageView) convertView; } imageView.setImageResource(mThumbIds[position]); return imageView; } // references to our images private Integer[] mThumbIds = { R.drawable.sample_2, R.drawable.sample_3, R.drawable.sample_4, R.drawable.sample_5, R.drawable.sample_6, R.drawable.sample_7, R.drawable.sample_0, R.drawable.sample_1, R.drawable.sample_2, R.drawable.sample_3, R.drawable.sample_4, R.drawable.sample_5, R.drawable.sample_6, R.drawable.sample_7, R.drawable.sample_0, R.drawable.sample_1, R.drawable.sample_2, R.drawable.sample_3, R.drawable.sample_4, R.drawable.sample_5, R.drawable.sample_6, R.drawable.sample_7 }; }

    Read the article

  • why custom state won't work with compound drawable?

    - by schwiz
    Hello I am trying to make a password registration widget that will show a little checkbox in the textbox when both password boxes match. I decided to go about this by extending EditText to implement a valid and an empty state and then just use a state-list drawable to handle everything else. I followed the same method that the CompoundButton uses to add a custom state and everything seems to be right but the image will never change no matter what the state is (custom state or even state_focused etc) Is there some reason that the compound drawables of a TextView wouldn't work as a state-list drawable? Or, am I doing something wrong? Here is attrs.xml <resources> <declare-styleable name="ValidyState"> <attr name="state_valid" format="boolean"/> <attr name="state_has_text" format="boolean"/> </declare-styleable> </resources> my selector <selector xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res/com.schwiz.test"> <item android:drawable="@drawable/emptyspace" app:state_has_text="false"/> <item android:drawable="@drawable/ic_valid" app:state_valid="true" app:state_has_text="true"/> <item android:drawable="@drawable/ic_invalid" app:state_valid="false" app:state_has_text="true"/> </selector> and in my overridden EditText class private static final int[] VALID_STATE_SET = { R.attr.state_valid }; private static final int[] HASTEXT_STATE_SET = { R.attr.state_has_text }; ... private void refreshDrawables(){ Drawable[] drawables = getCompoundDrawables(); for(int i = 0; i < drawables.length; i++){ if(drawables[i] != null) { drawables[i].setState(getDrawableState()); } } invalidate(); } @Override protected void drawableStateChanged() { super.drawableStateChanged(); refreshDrawables(); } @Override protected int[] onCreateDrawableState(int extraSpace) { final int[] drawableState = super.onCreateDrawableState(extraSpace + 2); if(hasText){ mergeDrawableStates(drawableState, HASTEXT_STATE_SET); } if(isValid){ mergeDrawableStates(drawableState, VALID_STATE_SET); } return drawableState; }

    Read the article

  • Trouble getting height of OverlayItem Drawable

    - by Bloudermilk
    Hey- I'm having some trouble getting a hold of the drawable a certain OverlayItem is using so I can calculate the height of it and properly offset the note that shows onTap. Here is my code to try to get that drawable: Drawable marker = item.getMarker(android.R.attr.state_focused); if (marker != null) int markerHeight = marker.getIntrinsicHeight(); marker ends up null. I'm using a drawable XML file with a selector for the different states of the OverlayItem's drawable. In it I'm specifying a drawable for the null state, state_focused, and state_pressed. Thanks for any help! -Nick

    Read the article

  • Contact Bubble EditText

    - by toobsco42
    I am trying to create contact bubbles in the MultiAutoCompleteTextView similiar to how it is implemented in the Google+ app. Below is a screen shot: . I have tried to extend the DynamicDrawableSpan class in order to get a spannable drawable in the background of a span of text public class BubbleSpan extends DynamicDrawableSpan { private Context c; public BubbleSpan(Context context) { super(); c = context; } @Override public Drawable getDrawable() { Resources res = c.getResources(); Drawable d = res.getDrawable(R.drawable.oval); d.setBounds(0, 0, 100, 20); return d; } } Where my oval.xml drawable is defined as so: <?xml version="1.0" encoding="utf-8"?> <shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="oval"> <solid android:color="#00000000"/> <stroke android:width="4dp" android:color="#99000000" android:dashWidth="4dp" android:dashGap="2dp" /> <padding android:left="7dp" android:top="7dp" android:right="7dp" android:bottom="7dp" /> <corners android:radius="4dp" /> </shape> In my Activity class that has the MulitAutoCompleteTextView, I set the bubble span like so: final Editable e = tv.getEditableText(); final SpannableStringBuilder sb = new SpannableStringBuilder(); sb.append("some sample text"); sb.setSpan(new BubbleSpan(getApplicationContext()), 0, 6, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); e.append(sb); However, instead of the oval shape displaying behind the first 6 characters in the string, the characters are not visible and there is no oval drawable in the background. If i change the BubbleSpan's getDrawable() method to use a .png instead of a shape drawable: public Drawable getDrawable() { Resources res = c.getResources(); Drawable d = res.getDrawable(android.R.drawable.bottom_bar); d.setBounds(0, 0, 100, 20); return d; } Then the .png will show up but the characters in the string that are a part of the span will not show up. How can I make it so that the characters in the span are displayed in the foreground, meanwhile a custom shape drawable gets displayed in the background? I attempted to also use an ImageSpan instead of subclassing DynamicDrawableSpan but was unsuccessful.

    Read the article

  • Standard Android Button with a different color

    - by Mike
    I'd like to change the color of a standard Android button slightly in order to better match a client's branding. For example, see the "Find a Table" button for the OpenTable application: The best way I've found to do this so far is to change the Button's drawable to the following drawable located in res/drawable/red_button.xml: <?xml version="1.0" encoding="utf-8"?> <selector xmlns:android="http://schemas.android.com/apk/res/android"> <item android:state_pressed="true" android:drawable="@drawable/red_button_pressed" /> <item android:state_focused="true" android:drawable="@drawable/red_button_focus" /> <item android:drawable="@drawable/red_button_rest" /> </selector> But doing that requires that I actually create three different drawables for each button I want to customize (one for the button at rest, one when focused, and one when pressed). That seems more complicated and non-DRY than I need. All I really want to do is apply some sort of color transform to the button. Is there an easier way to go about changing a button's color than I'm doing?

    Read the article

  • Android Create Layered drawable in XML

    - by Lyubomyr Dutko
    Hello, I would like to create a drawable in XML that should include: image drawable color drawable The color drawable provides white transparent color. So, as a result we would have image with some white transparent layer on top. I have tried to use LayerDrawable, but it fails to be created during application launch: <LayerDrawable xmlns:android="http://schemas.android.com/apk/res/android"> <BitmapDrawable android:src="@drawable/button_play" /> <ColorDrawable android:color="#80FFFFFF"/> </LayerDrawable> Could you please advice what is wrong here? Thanks.

    Read the article

1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >