custom-view

only one color is displayed in time

戏子无情 提交于 2019-12-02 09:44:15
问题 I'm developing paint app the problem is when i choose color and paint and then pick different color the whole paint color changes to the new color can any one tell why this is happening and how to solve this ? and how to add eraser to this? imageview DrawView here : public class DrawView extends ImageView { private ArrayList<Point> mTouches; int paintColor; public int setcolor(int a){ paintColor=a; return paintColor;} // Java constructor public DrawView(Context context) { super(context); init

How to pass variables to custom View before onDraw() is called?

三世轮回 提交于 2019-12-01 14:34:14
What I am trying to achieve: measure a container View in my layout, mainContainer, that is defined in the XML pass the mainContainer's width and height to a different custom View before onDraw() is called I want to pass the width and height so the custom View knows where to draw canvas.drawBitmap using coordinates The custom view will be programmatically created from code How can I pass the measured int width and int height to my custom View before onDraw() is called? Custom View public class AvatarView extends ImageView { private Bitmap body; private Bitmap hat; public AvatarView(Context

How to pass variables to custom View before onDraw() is called?

岁酱吖の 提交于 2019-12-01 12:14:21
问题 What I am trying to achieve: measure a container View in my layout, mainContainer, that is defined in the XML pass the mainContainer's width and height to a different custom View before onDraw() is called I want to pass the width and height so the custom View knows where to draw canvas.drawBitmap using coordinates The custom view will be programmatically created from code How can I pass the measured int width and int height to my custom View before onDraw() is called? Custom View public class

how to Custom Button (has two TextFields) on Android

你离开我真会死。 提交于 2019-11-30 19:17:48
问题 I need to develop a button that has two label in. I find some good articles about custom views, but I can't imagine that how can I create a myButton Class(with custom layout in it) extends button... is it possible.. Also in XML some views,layouts... How can we do this?? 回答1: You can create a custom view. I have used Layout as a button by setting custom button style to the layout and have added two textViews to it, this way: <LinearLayout android:id="@+id/customButtonLayout" android:layout

How can I get the canvas size of a custom view outside of the onDraw method?

久未见 提交于 2019-11-30 14:30:51
问题 I need to be able to access the size of the view's canvas to perform some calculations. For some reason, the size of the view passed to onSizeChanged is different than the size of the canvas passed to onDraw . My current workaround uses a boolean flag to determine when I need to do the calculations. The ideal solution would allow me to do these calculations in the onSizeChanged method, so I'm wondering... is there any way I can get ahold of the Canvas object (or at least it's dimensions)

How can I get the canvas size of a custom view outside of the onDraw method?

主宰稳场 提交于 2019-11-30 10:52:10
I need to be able to access the size of the view's canvas to perform some calculations. For some reason, the size of the view passed to onSizeChanged is different than the size of the canvas passed to onDraw . My current workaround uses a boolean flag to determine when I need to do the calculations. The ideal solution would allow me to do these calculations in the onSizeChanged method, so I'm wondering... is there any way I can get ahold of the Canvas object (or at least it's dimensions) outside of the onDraw method? My code is below. It is draws the radius of a circle at a given angle. When I

How to scroll “infinitely” wide view in Android?

萝らか妹 提交于 2019-11-30 10:36:39
I am pondering the alternatives on how to scroll an "infinite", scale-like, control in android. The simple idea is to redraw the entire view on each scroll movement, but somehow it doesn't seem like the proper way. It is possible to draw the contents before-hand, but I have no clue how wide I should make the view in the first place, and what happens when the user scrolls to the end of the view? I guess I need to extend the view towards that direction. Should I go towards programatically adding (and removing) chunks of view to a linear layout? It would be great to hear what experiences are out

Android: Custom view based on layout: how?

故事扮演 提交于 2019-11-30 09:41:19
I am building a Android app and I am a bit struggling with custom Views. I would like to have a reusable View that consist of a few standard layout elements. Let's say a relativelayout with some buttons in it. How should I proceed. Should I create a custom view class that extends RelativeLayout and programmaticly add those buttons? I would think that's a bit overkill? What's the way to do it properly in Android? Here are some rough steps regarding one way to create a custom aggregate view: extend RelativeLayout Provide a constructor in your new class that accepts Context and AttributeSet,

How do I create a custom view class Programmatically? [closed]

帅比萌擦擦* 提交于 2019-11-30 08:49:30
I want to create a very simple customView with a few UIlabel on it, How should i do this . any tutorial or suggestion would be appreciated . I am new to this , didn't try before. I tried this with xib. @interface MyCustomView : UIView @property (strong, nonatomic) IBOutlet UILabel *Label; @end Implementation #import "MyCustomTimer.h" @implementation MyCustomView -(id)initWithCoder:(NSCoder *)aDecoder{ if ((self = [super initWithCoder:aDecoder])){ [self addSubview:[[[NSBundle mainBundle] loadNibNamed:@"MyCustomView" owner:self options:nil] objectAtIndex:0]]; } return self; } @end But i need to

Custom View Extending Relative Layout

江枫思渺然 提交于 2019-11-30 06:54:22
问题 package com.binod.customviewtest; import android.content.Context; import android.view.LayoutInflater; import android.widget.RelativeLayout; public class CustomView extends RelativeLayout{ public CustomView(Context context) { super(context); // TODO Auto-generated constructor stub // LayoutInflater mInflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE); LayoutInflater mInflater = LayoutInflater.from(context); mInflater.inflate(R.layout.custom_view , this, true);