custom-view

Android ProgressDialog with setContentView

喜你入骨 提交于 2019-11-28 09:23:58
I've read a hell of a lot about this, and can't see anyone who's done or tried it before. So I've got an object that extends ImageView, then within this I call a progress dialog and set the progress dialogs's content to the imageview (i.e. attempting to draw the progress dialog in the imageview..view.) loadingProgressDialog.setContentView(this); //this is: LoaderImageView extends ImageView loadingProgressDialog.setIndeterminate(true); loadingProgressDialog.show(); And I get the error: requestFeature() must be called before adding content Now I've seen this error before on loads of posts and

Android drawing button to canvas with custom view?

白昼怎懂夜的黑 提交于 2019-11-28 08:34:26
How can I draw a button on top of the canvas in a custom view? (Preferably on the mid-right side) Is there something I have to call before doing the button.draw(canvas)? public class MyClass extends View { public Simulation(Context context) { super(context); pauseButton.setText("TestButton"); pauseButton.setClickable(true); pauseButton.setOnClickListener(new OnClickListener() { public void onClick(View v) { Log.i(TAG, "Button Pressed!"); } }); public onDraw(Canvas canvas) { super.onDraw(canvas); pauseButton.draw(canvas); } } Thanks for your time Lumis You cannot insert a button into canvas.

Android - Is it possible to create a custom library to use across several applications?

天大地大妈咪最大 提交于 2019-11-28 06:52:58
Is it possible to create a custom library in Android (having its own layout resources) for use across several Android applications? I created a regular *.jar file but when I tried to create/style my views dynamically most of the properties do not work. Even referencing simple styles from the android.jar file such as android.attr.listSeparatorTextViewStyle did not work. I created an Android project without any Activity, having its own resource files and then referenced this project from another Android project to use in its build path. Everything seems to work fine but the emulator keeps

Android Sliding Up View

泄露秘密 提交于 2019-11-28 01:30:45
问题 I need to do a Sliding Up View wich should slide up from the bottom of the screen when I click a button. It has to show on the bottom of the screen and I need to slide/drag it to the center of the screen. The images below explain it better. almost like the AndroidSlidingUpPanel from "umano" which you can find here: The problem is that I want the first child (The content of my View - an image for example) to fill all the screen and also I want the second child(the actual bottom bar) to be

Custom SurfaceView causing NoSuchMethodException

对着背影说爱祢 提交于 2019-11-27 22:37:50
问题 I have a custom View extending SurfaceView. The XML layout is <com.myPackage.MyCustomView android:id="@+id/mycview" android:layout_width="fill_parent" android:layout_height="fill_parent"/> The class is : public class MyCustomView extends SurfaceView{ public float[] xpositions; public float[] ypositions; public String[] units; public MyCustomView(Context context, float[] xpos, float[] ypos,String[] u) { super(context); xpositions=xpos; ypositions =ypos; units=u; } } In the context Activity for

Android custom view Bitmap memory leak

血红的双手。 提交于 2019-11-27 18:50:53
I've got a custom view in which I need to draw two bitmaps, one is a background, representing the image of a map and one is a pin which will be drawn on top/left position in canvas. The both images are drawn onDraw and remain the same during the live of the activity that contains the view. After a while I get a OutOfMemoryError: bitmap size exceeds VM budget This means that I have a leak and the bitmaps don't get garbage collected. I asked this question before, but now the situation changed a little. I made a init method where I set the bitmaps I want to use but this still isn't a good

Slow load time for custom UIView with UITextView property in Swift

泪湿孤枕 提交于 2019-11-27 17:11:46
问题 I originally asked this question. I had assumed that the reason for the slow load time of my custom view was because of layering multiple views on top of each other or perhaps because of some recursion problem. However, after cutting out more and more code to see what would make a difference, it came down to whether I had a UITextView present or not. Because the apparent source of my problem is so different than what I was expecting in my first question, I decided to start a new question

android data binding with a custom view

橙三吉。 提交于 2019-11-27 11:02:17
The Android data binding guide discusses binding values within an activity or fragment, but is there a way to perform data binding with a custom view? I would like to do something like: <LinearLayout android:layout_width="match_parent" android:layout_height="match_parent"> <com.mypath.MyCustomView android:id="@+id/my_view" android:layout_width="match_parent" android:layout_height="40dp"/> </LinearLayout> with my_custom_view.xml : <layout> <data> <variable name="myViewModel" type="com.mypath.MyViewModelObject" /> </data> <LinearLayout android:layout_width="match_parent" android:layout_height=

Android ImageView size not scaling with source image

混江龙づ霸主 提交于 2019-11-27 10:19:23
I have a few ImageViews inside a LinearLayout. I need to scale down the ImageViews so that they maintain their aspect ratios whilst fitting inside the LinearLayout vertically. Horizontally, I just need them to be adjacent to each other. I've made a simplified test bed for this which nests weighted Layouts so that I have a wide, but not very tall, LinearLayout for the ImageViews - <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent">

Custom UIView loaded from Xib

风格不统一 提交于 2019-11-27 07:02:14
问题 I have created a custom subclass of UIView along with a xib file and declared IBOutlets and IBActions within the custom class. @interface ContactUsView : UIView @property (nonatomic, weak) IBOutlet UIButton *displayCloseButton; - (IBAction)callButtonPressed:(id)sender; - (IBAction)emailButtonPressed:(id)sender; - (IBAction)displayCloseButtonPressed:(id)sender; @end In the xib file I have dragged in a UIView to represent my custom view. I have set: Files owner = to my custom class Have set the