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
2 answers

Trouble referring to a custom View in a layout XML

I am trying to refer to a custom View in the helloWorld XML layout but I get the following exception: Error inflating class acme.my.MyTextView. However, I am able to instantiate the view and add it to the main content view manually. The custom…
Fredrick
  • 1,210
  • 2
  • 15
  • 24
0
votes
0 answers

Custom actionbar is scaled when keyboard appears in android

I have a layout which contain an actionbar and scrollview holding some edittexts. When I click on edittext, keyboard appears and actionbar is scaled vertically. How can I make actionbar not be scaled. I added in manifest:…
0
votes
1 answer

Cocoa: NSToolBar with Custom Views. Animation issues

So I got a Window: Window.xib I got a WindowController too: WindowController.h reads: #import @interface MainWindowController : NSWindowController { IBOutlet NSView *firstView; IBOutlet NSView *secondView; IBOutlet…
Dmitri K.
  • 197
  • 1
  • 13
0
votes
1 answer

NSStatusItem with custom view, alpha value, and multiple displays

I have an app which has a NSStatusItem that uses a custom view. I apply an alpha value to the status item's view when a process in the app in inactive. This works fine, except on OS X 10.9 - 10.10 when multiple displays (monitors) are present. The…
0
votes
3 answers

How to create view programatically with .xib?

I got a simple idea - suppose we have singletone object that works similar to local notifications - when it's called it should show message view on the current window, wherever user is now. Message view is contained in .xib and got next…
htzfun
  • 1,231
  • 10
  • 41
0
votes
1 answer

CustomView, Mac, Swift, let myEmptyView = self.moveView(frame: viewRect) viewRect cannot be found

I am playing with custom View in Swift on Mac. I have set up custom view in the mac window, I have linked to the swift file and in the swift file I have the following: import Cocoa class moveView: NSView { override func drawRect(rect: NSRect) …
aster007
  • 335
  • 2
  • 13
0
votes
2 answers

Custom Actionbar doesn't override default Actionbar

I implemented custom action bar which contains an image and button. It is working fine but this custom actionbar gets displayed below main action bar.How should i override it on main bar.Please don't get confused with app name or title. Code for…
Nikhil Khurana
  • 422
  • 1
  • 5
  • 12
0
votes
1 answer

Alternetive to TableView

I'm doing an app that retrives data from a server and show it in a view using a tableview. What i'd really like to do is a view showing the content like images side by side. Just like this image: Is there some native iOS component like TableView,…
Cilas
  • 172
  • 1
  • 14
0
votes
0 answers

Add tableView to a custom View

I'm sure this might be fairly easy but I'm unable to do it. I have a custom View xib and on basis of either segment selection I want to show one of my two tableViews. When tableView xib is loaded with _userProfileView = [[[NSBundle mainBundle]…
Misha
  • 685
  • 8
  • 20
0
votes
1 answer

Add custom view in UIAlertController in iOS

I have used below code to show action sheet with Tweet, Facebook and Cancel button. - (void)shareApp:(id)sender { NSString *strCancel = NSLocalizedString(@"Cancel", nil); NSString *strTweet = NSLocalizedString(@"Tweet", nil); NSString…
Jayprakash Dubey
  • 35,723
  • 18
  • 170
  • 177
0
votes
2 answers

Display curve shape progress in custom View

I am working with custom view which is in a circle shape. Almost i have done it with creating a custom class and implemented that. But my problem is too show a different progress in a curve shape with different color and which is depends on dynamic…
Piyush
  • 18,895
  • 5
  • 32
  • 63
0
votes
0 answers

Changing child views dynamically in customview, fails in reverting back to previous child view

In my custom view I use the below simple method to change child views dynamically: private void changeChildView(final View oldView, final View newView) { final int viewIndex = indexOfChild(oldView); removeViewAt(viewIndex); …
abedfar
  • 1,989
  • 24
  • 21
0
votes
1 answer

Custom created View

I have created a Custom View that displays the digits of a number in separate rectangular boxes : The code for the onDraw() is as given below : protected void onDraw(Canvas canvas){ Rect rect = new Rect(20, 20, 170, 220); int xx =…
Arjun Issar
  • 672
  • 4
  • 13
  • 32
0
votes
1 answer

iOS datasource and outlet references

I viewed some Stanford iOS development classes on Youtube, and I found something that's not clear to me. In the lecture the professor explains how to create custom views and custom data source classes, and the code is the…
user2340612
  • 10,053
  • 4
  • 41
  • 66
0
votes
0 answers

Fragment calling view method

I have a fragment with a custom view in it. This custom view is a Sudokuboard. SInce the view needs the starting numbers my thought was to give this from the fragment onCreate using a view method i added ( public void add_numbers(String) ) But when…
Aune
  • 245
  • 1
  • 4
  • 9