Questions tagged [declare-styleable]

56 questions
89
votes
2 answers

Declaring styleable attributes in Android

There's precious little documentation about the declare-styleable tag by which we can declare custom styles for components. I did find this list of valid values for the format attribute of the attr tag. While that's nice as far as it goes, it…
Ted Hopp
  • 232,168
  • 48
  • 399
  • 521
35
votes
4 answers

How to declare several stylable attributes with the same name for different tags?

I want both my ViewA and ViewB to have the "title" tag. But I can't put this in attrs.xml:
Andreas
  • 7,470
  • 10
  • 51
  • 73
28
votes
1 answer

Get the resource id for the drawable reference used in styled attribute

Having this custom view MyView I define some custom attributes:
ilomambo
  • 8,290
  • 12
  • 57
  • 106
24
votes
2 answers

Difference between declare-styleable and style

I've begun playing around with styles and such in my android applications, and I have gotten everything working so far. I quite understood the 'style' section of the guide. But, looking around, as in this thread, I can't really figure out the…
Stephan
  • 1,858
  • 2
  • 25
  • 46
18
votes
7 answers

ERROR: In MenuView, unable to find attribute android:preserveIconSpacing

I had created an app and when tried to run,get an error like this. ERROR: In MenuView, unable to find attribute android:preserveIconSpacing Problems and at end of R.java please help me to fix this issue
Sonia John Kavery
  • 2,099
  • 2
  • 20
  • 36
18
votes
2 answers

How to define an array of integers in a declare-styleable?

I'm implementing my own for a custom View (following the instructions here). I'd like to be able to specify an array of integers as one of the possible XML attributes. How do I: Specify the integer array as an XML attribute in…
16
votes
1 answer

Creating default values for custom attributes using styles and themes

I have several custom Views in which I have created custom styleable attributes that are declared in xml layout and read in during the view's constructor. My question is, if I do not give explicit values to all of the custom attributes when…
happydude
  • 3,869
  • 2
  • 23
  • 41
14
votes
6 answers

Android library project uses declare-styleable -- how to compile?

I have a custom preferences control that I have defined a few attributes for in values/attrs.xml. Just to focus the conversation, here is an example of attributes that could be found in values/attrs.xml:
Jonathan Schneider
  • 26,852
  • 13
  • 75
  • 99
11
votes
1 answer

Android: How to get an attribute from a super class of a custom view

I have a custom view A that has a TextView. I Made a method that returns the resourceID for the TextView. If no text is defined the method will return -1 by default. I also have a custom view B that inherits from view A. My custom view has the text…
10
votes
1 answer

Can someone explain me declare-styleable XML tag in this example and the theory behind its use?

I'm reading Beginning Android 4 Development and in chapter 5 it talks about Gallery and ImageVievs and introduces the declare-styleable XML tag without explaining its purpose.. I tried to find some info also on the reference, without luck.. For…
Gianni Costanzi
  • 6,054
  • 11
  • 48
  • 74
8
votes
1 answer

What's the point of declare-styleable?

Suppose I am making some new views with styleable attributes. I declare them thusly (this is how the documentation says to do it:
Timmmm
  • 88,195
  • 71
  • 364
  • 509
7
votes
1 answer

Android: How do you have multiple attr with same enum?

I have an attr defined as an enum with a list of values: I would like to use multiple attr with different names within the…
7
votes
1 answer

Changing theme of an activity without recreating activity

I have an activity . In that on a button click I want to change the theme but everywhere I found that theme can be set only once and that too before setContentView. Restarting an activity is not an option for me. Maybe using attrs has to do…
user2781627
  • 455
  • 5
  • 17
6
votes
1 answer

Android custom layout attribute "reference attribute" format?

I have a custom view (that extends viewgroup) and I have specified some custom attributes defined in attrs.xml....
6
votes
1 answer

Exception thrown during TypedArray#getTextArray()

This is my first time creating a custom view and I'm trying to populate it with entries via XML -- in a manner similar to a Spinner. I'm obviously doing something wrong here, but I've styled my approach after the Spinner, so I fail to see what has…
dm78
  • 1,570
  • 1
  • 16
  • 28
1
2 3 4