Showing posts with label View. Show all posts
Showing posts with label View. Show all posts

Android Custom View: PlayStation Knob - Part 1: Getting Started

This is part 1 of the series "Android Custom View: PlayStation Knob", in which I will be creating an Android Custom View that acts just like the PlayStation Analogue Knob:


In this part, you will be able to:

  1. Create the Custom View
  2. Create Custom Attributes
  3. Use your View in an Activity
  4. Capture Touch Events to move the knob

How to get width/height of a View

As the idea of the Android evolved, Android has received wide attention and deployed on a very wide range of devices. Android UI had to move and make developers' life easier: AbsoluteLayout got deprecated. It is very logical because your app will be installed on very small devices and very large devices and all the devices in between.

Now, it is all WRAP_CONTENT, FILL_PARENT/MATCH_PARENT. Yet, a developer sometimes needs to know the dimensions of his view to do some extra tweaks to perfect his ui.

So, what is the best way to do so?

Applying style to views dynamically in java code

In my answer to Applying style to views dynamically in java code on Jun 25 at 18:51, I thought setting a style to a view dynamically would be as simple as passing the style to the constructor of your view. A couple of minutes ago, I had a notification and a comment (Thank you for it) saying that this does not work. I had a freaking -1 ):

VibratingTextView

please read the disclaimer
please read the formatting notes

.
Here it comes the first real widget in this library which by the way I am still unsure about its name or its components' names.

What's this really:



Anyway what is the idea behind this!?

To be able to move each letter,

Creating a skinny ProgressBar

Ok.. So I want to create something like this: (for no reason :P)

It turned out to be a really simple procedure: