fhucho wrote:
> I have a custom View, it is created from xml - how can I obtain the
> android:layout:width value in the constructor View(Context x,
> AttributeSet a) ?

To get at a custom attribute, you would use code like this:

TypedArray a=ctxt.obtainStyledAttributes(attrs,
                                                R.styleable.Meter,
                                                0, 0);
                
max=a.getInt(R.styleable.Meter_max, 100);
incrAmount=a.getInt(R.styleable.Meter_incr, 1);
decrAmount=-1*a.getInt(R.styleable.Meter_decr, 1);
        
a.recycle();

(from http://github.com/commonsguy/cw-advandroid/tree/master/Views/Meter/)

For android:layout_width, presumably you would use
android.R.styleable.ViewGroup_Layout_layout_width, though I have not
tried that.

However, in theory, that attribute should be handled for you, I would
think. You would negotiate the size in onMeasure().

-- 
Mark Murphy (a Commons Guy)
http://commonsware.com | http://twitter.com/commonsguy

Android App Developer Training: http://commonsware.com/training.html

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to