Office Hours — Today, May 4

Yesterday, May 3

May 4
7:25 PM
Mark M.
has entered the room
Mark M.
turned on guest access
7:30 PM
Joshua C.
has entered the room
Joshua C.
Hello. :)
Mark M.
hello, Joshua!
how can I help you today?
Joshua C.
Well... I'm still actually working on a very unusual keyboard (you may remember my previous question the other day)...
I am now not working with the IME part, but simply trying to implement the keyboard itself in an activity.
Mark M.
I remember bits and pieces
Joshua C.
So... basically I'm trying to create a Layout that arranges items in more than just rows and columns...
Mark M.
most keyboards that I see at least use rows
Joshua C.
This will use rows... but some of the rows will be curves, going from one edge of the screen to another.
Mark M.
um, OK
7:35 PM
Joshua C.
So... admittedly I'm very new to android and a pretty rusty coder... but so far I'm seeing that I need a Layout (inherited from ViewGroup), and View (this is called Key, the widget for each key itself...
Mark M.
yes to both
Joshua C.
And then the XML file that needs to describe where the keys go...
Mark M.
possibly
you need to wire the ViewGroup and Views
er, wire them together
that could be via a layout XML resource
it does not have to be
it could be done purely in Java
Joshua C.
Yes... I would like to define the key layout in XML.
Mark M.
OK
Joshua C.
For ease of development...
Mark M.
I'm not sure that in this case it would be worthwhile, but that's your call
Joshua C.
The keyboard layout itself will have sections... one for each edge and any number of curves, going from one edge to another.
So... one question... can I just create arbitrary properties and tags in my XML layout file?
Such as this for example:
View paste
<curve
        android:from = "bottom"
        android:to = "pinky-side"
        android:height = "10em" >

    </curve>
Mark M.
um
is that supposed to be a layout XML resource?
or is that just some XML that you are going to parse (e.g., in res/xml/)?
Joshua C.
Well... I need to create a whole new format of layout resource... which yes, I will have to implement the parsing of.
7:40 PM
Mark M.
that's not how it works
7:40 PM
Joshua C.
I need to create a completely custom layout... or at least, that's the way I've thought made the most sense. I'm open to other directions...
Mark M.
leastways, it will not be a "layout resource"
you are certainly welcome to define your own XML structures and put them in res/xml/
or, you can stick with the existing layout resource structure, in which case your XML will need to shift a bit
Joshua C.
Okay, they go in res/xml/... but an actual "layout resource" has to be of the usual kind.
Mark M.
yes
Joshua C.
I don't think the exist layout resource structure will do what I want.
Mark M.
I am not completely certain why not, but, again, that's your decision to m ake
er, make
Joshua C.
Well... perhaps I can, I'm still figuring out how flexible the layout resource structure is... so... there are various different "Layouts", right... RelativeLayout, BoxLayout, etc... and these all have the same structure to their "layout resources"?
Mark M.
by "structure", I am referring to XML element and attribute names
View paste
<com.joshua.aweseomeapp.Curve
        curve:from = "bottom"
        curve:to = "pinky-side"
        curve:height = "10em" />
that is a valid layout resource
7:45 PM
Joshua C.
Aha....
Mark M.
where your ViewGroup is named com.joshua.awesomeapp.Curve
you will need to declare the possible attributes in a res/values/attrs.xml file
so Android knows what to do with curve:*
Joshua C.
Okay... great... and then I from, to, and height are all members of my Curve class (extends ViewGroup)?
Mark M.
that's up to you
you will get an AttributeSet in a constructor, from which you will read the attribute values
where and how you save those for your use is your call
my chapter on custom views gets into this somewhat, particularly with the ColorMixer sample: https://github.com/commonsguy/cw-omnibus/tree/m...
what you will be doing is orders of magnitude more complex
Joshua C.
Ah... okay, I'm starting to understand...
Yes.. a tall order, I know... and I'm only just getting started.
Mark M.
your keys would be children of the Curve element
whether those are custom views, or just ImageButton with styling, would be up to you
Joshua C.
So... can you tell me a little about (or point to where in your enormous book I can find) the connection between the View and the ViewGroup... the XML file defines where the rows and such will be placed... the ViewGroup (Layout) gets that info... and then how does the data of where to draw get from the ViewGroup to the Views (Widgets) themselves?
7:50 PM
Mark M.
no, largely because I don't do much with custom ViewGroups
(in the book or elsewhere in life)
they make my head hurt
Joshua C.
Hmm... darn. Haven't I just picked all the topics you don't cover to work on. ;)
Mark M.
Joshua C.
Everything is all done in rectangles... everywhere... and I am determined to put widgets in curves. ;)
That article looks like a good place to start.
Mark M.
unfortunately, I am not finding a video of Lucas' presentation at droidcon UK 2014(?)
there are articles and such floating around
but it's a bit of a niche area
you might also look at some existing libraries
for example, there are a couple of radial menu implementations floating around
Joshua C.
Oooh, interesting. I will look for that.
Mark M.
those would give you curves, plus (probably) custom views/groups
Joshua C.
Yes... it looks like kind of in the vein of where I'm going....
Mark M.
7:55 PM
Mark M.
those would be starting points, albeit pure code, not explanatory material
probably none will solve your problem "out of the box", though
Joshua C.
Yes indeed... good references... yes, certainly none are exactly what I'm going for... but they give me hope what I'm working towards is possible...
Mark M.
oh, I have little doubt that what you want is possible
similarly, I have little hope that I will be of much direct use beyond the basics
Joshua C.
Well, that's good to hear! That's some good leads for now... I'll chew on all that and keep poking at this. You'll hear from me again at another time. I'm very glad to have this resource. I hope you'll excuse my vague and ignorant questions. :)
8:00 PM
Mark M.
your questions are fine
Joshua C.
Thanks. Have a great day, I'll get back to it for now. :)
Mark M.
you are very welcome
8:10 PM
Joshua C.
has left the room
8:30 PM
Mark M.
turned off guest access

Yesterday, May 3

 

Office Hours

People in this transcript

  • Joshua Chambers
  • Mark Murphy