Questions tagged [custom-view]

It is possible to create custom views by:

  • Compound views - combining views with a default wiring

  • Custom views - creating your own views

    a) by extending an existing view, e.g. Button, TextView, EditText, ListView, CheckBox, RadioButton, Gallery, Spinner, AutoCompleteTextView, ImageSwitcher, and TextSwitcher.

    b) by extending the View class

Creating custom views

By extending the View class or one of its subclasses you can create your custom view.

Creating your own View subclasses gives you precise control over the appearance and function of a screen element.

For drawing view use the onDraw() method. In this method you receive a Canvas object which allows you to perform drawing operations on it, e.g. draw lines, circle, text or bitmaps. If the view should be re-drawn you call the invalidate() method which triggers a call to the onDraw() method of this view.

If you define own views, ensure you review the ViewConfiguration class, as it contains several constants for defining views.

To draw your Views you typically use the 2D Canvas API.

Useful links:

644 questions
0
votes
3 answers

Making my custom view to be extended by many classes

i'm a new in android and that's the first time for me to ask, so i'm sorry if the question is easy... i'll make an app which will contain many classes, but all of them are similar in idea.. (for example, i have a class which will show four pics of…
Ali Zein
  • 28
  • 4
0
votes
1 answer

Rendering Problems in android studio xml files

How to fix the following? "The following classes could not be instantiated:" If I don't close this warning the preview cannot show the custom widget, but it's ok when run the project.
Thinsky
  • 4,226
  • 3
  • 13
  • 22
0
votes
1 answer

Android define a custom group view

I'm implementing a dialler screen and I want to make the keypad as a custom view (so that I can embed it directly in other UI if needed) I've defined a layout xml file keypad.xml so I'm able to show the keypad at least in my dialler screen. I'm…
xialin
  • 7,686
  • 9
  • 35
  • 66
0
votes
1 answer

Custom UIActivityViewController-like view that slides up and down

Is there a way to subclass or customize UIActivityViewController to create a sort of custom view? For example, see the image below from the app Overcast. I want to create a view similar to that, where if you tap a button, the view pops up and when…
tentmaking
  • 2,076
  • 4
  • 30
  • 53
0
votes
2 answers

Show hidden views of List item on click of button outside the list

I am developing an Android Application. In this app I am making a list of views using code given below. In each item of list there is delete button with visibility "Gone". Now there is another button Edit outside the list, on click of edit button I…
Balvinder Singh
  • 580
  • 6
  • 19
0
votes
1 answer

Android: best practice for building a 2D avatar customization

I am trying to create a 2D avatar customizer without using a Game Engine inside my Android app. I will basically have a PNG image as a base to start with. Then I want to layer other images on top of the base to customize the character. What would…
The Nomad
  • 7,155
  • 14
  • 65
  • 100
0
votes
1 answer

Mysterious behavior of custom ListView (drawing item on Canvas) in android 2.3.3

I'm creating custom ListView. Adapter: public class CustomListEventsAdapter extends BaseAdapter { private Context context; private List> values; public CustomListEventsAdapter(Context context, List> values)…
0
votes
1 answer

Inflate a custom view from XML, then set her height and witdh programmatically

I'm loosing myself in an custom size View problem since a couple of days. After some long research, I finally decide to ask your help... please ! T_T In my app, I created a custom View with the XML calendrieradmin_day.xml :
0
votes
1 answer

setNeedsDisplay:YES does not draw

So I'm having an issue drawing a custom view inside my existing window. I have a custom class called GraphView that I use to draw a graph of values onto the view. The graph gets passed variables each second and should get redrawn via…
0
votes
1 answer

Android customview get pixel

I have a custom view and I want to get pixel by a given position on ACTION_UP event. public class MyView extends View { private Bitmap mBitmap; private Canvas mCanvas; private Paint mPaint; public MyView(Context context) { …
Zbarcea Christian
  • 9,367
  • 22
  • 84
  • 137
0
votes
0 answers

drawPaint and drawText in a customView

I don't understand the difference between the two methods drawPaint and drawText ? If I want to define how a customed TextView, and that I want to define its own Typeface and TextColor: do I have to define a textPaint object then use methods like…
akari
  • 617
  • 1
  • 11
  • 32
0
votes
1 answer

Unrecognized selector sent to instance after adding a view controller to a tab bar controller

I have a custom view controller with a custom segue. When I try to launch the application it crashes with an 'NSInvalidArgumentException', reason: '-[UtilizationVC setUtilizationManager:]: unrecognized selector sent to instance error…
0
votes
1 answer

Adding NSMatrix of buttons (NSRadioModeMatrix) in custom view, setting target/action

I am subclassing NSTabView to customise the appearance. I want to use an NSMatrix of NSButtonCells to select the tabs. I managed to add the NSMatrix with buttons in the initWithFrame: method of my NSTabView subclass. What I can not get to work is…
Martin
  • 333
  • 1
  • 3
  • 6
0
votes
0 answers

how draw a shape with android canvas that follow finger smoothly

I'm trying to draw circle that follow my finger over the screen. it's done but if I move finger fast, circle move isn't smooth. customview.java public customview(Context context, AttributeSet attrs) { super(context, attrs); this.context…
MHP
  • 2,613
  • 1
  • 16
  • 26
0
votes
0 answers

Android: Draw image on canvas of particular size

I am adding 1 layout dynamically. In that adding custom view. now I want to draw image on canvas exactly of same size as the size of that layout. Below is the code of my custom view which i have tried. public BlockView(Context context, Bitmap…
Dig
  • 254
  • 1
  • 9