android-canvas

left drawable alignment with text in android

那年仲夏 提交于 2019-12-02 05:08:06
问题 I am new to custom view and didn't know much about canvas in android, I wanted to align a left drawable to right side of layout along with the text(whether multiline or not) of same textview as in this image In the above image, i wanted to align $ image along with text($20.0 -$90.0 /hour) and must be in center if text is multiline and i don't want to use any extra layouts. Thanks in advance This is my basic xml, <RelativeLayout android:layout_width="match_parent" android:layout_height="wrap

How to implemement undo features in painting application in Android?

感情迁移 提交于 2019-12-02 04:28:30
问题 i want to do undo features in in my application.. for this i searched i net found that take arraylist of x,y points which i have done below code i am unable for undo the drawings ?? public Drawview(Context context, float x, float y, int r) { super(context); mBitmap = Bitmap.createBitmap(800, 1200, Bitmap.Config.ARGB_8888); // mainbitmap.add(mBitmap); //System.out.println("**mBitmapPaint***"+mBitmapPaint); mCanvas = new Canvas(mBitmap); mPath = new Path(); mBitmapPaint = new Paint(Paint.DITHER

Android: Draw text on ImageView with finger touch

心不动则不痛 提交于 2019-12-02 04:25:54
i completed the drawing text on ImageView and i saved the final image in sd card. My problem is, when i am touching the screen to draw the text, my image in the ImageView is disappearing. Code import java.io.File; import java.io.FileOutputStream; import android.net.Uri; import android.os.Bundle; import android.os.Environment; import android.os.StrictMode; import android.annotation.SuppressLint; import android.app.Activity; import android.content.Intent; import android.graphics.Bitmap; import android.graphics.Bitmap.CompressFormat; import android.graphics.Canvas; import android.graphics.Color;

android: convert canvas to bitmap then save to SD card

心已入冬 提交于 2019-12-02 03:59:35
i'm developing an android app where I can draw on a canvas. I want to convert my canvas to bitmap and then save it in jpeg format on my sd card.. how can i properly do this? Something like that should work : http://developer.android.com/reference/android/view/View.html#getDrawingCache(boolean) public void toJPEGFile(){ File folder = new File(Environment.getExternalStorageDirectory()+"/folder/"); if(!folder.exists()) folder.mkdirs(); try { this.setDrawingCacheEnabled(true); FileOutputStream fos = new FileOutputStream(new File(Environment.getExternalStorageDirectory()+"/folder/file")); Bitmap

Android: How do I scale a bitmap to fit the screen size using canvas/draw bitmap?

雨燕双飞 提交于 2019-12-02 03:24:21
问题 I am taking an image and drawing it to the screen using canvas. I want to scale it based on the screen size. This is what I tried, but it cuts off a large chunk of the image: DisplayMetrics metrics = context.getResources().getDisplayMetrics(); int width = metrics.widthPixels; int height = metrics.heightPixels; Bitmap bitmap = BitmapFactory.decodeResource(context.getResources(),R.drawable.myimage); bitmap = Bitmap.createScaledBitmap(bitmap, width, height, false); Rect frameToDraw = new Rect(0,

Custom Draw Line Between Two Views Not Working Properly

萝らか妹 提交于 2019-12-02 03:17:33
I am trying to draw lines between buttons in android. I created one custom class which draw line between buttons inside relative layout(Relative Layout is parent layout). Here is my MatchTheColoumnDrawView.java class which accepts context, startView, endView, lineColour, endCircleColour, thickness(in float), direction(LEFT_TO_RIGHT OR RIGHT_TO_LEFT). import android.content.Context; import android.graphics.Canvas; import android.graphics.Color; import android.graphics.DashPathEffect; import android.graphics.Paint; import android.graphics.Path; import android.util.Log; import android.view.View;

Android Development: Combining small tiles/bitmaps into one bitmap

折月煮酒 提交于 2019-12-02 02:00:48
Im trying to get all my small images like grass, water and asphalt and so on, into one bitmap. I have an Array that goes like this: public int Array[]={3, 1, 3, 3, 1, 1, 3, 3, 3, 3, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ,1 ,1, 1, 1 ,1 ,1 ,7 ,7 ,7, 7, 7 ,7, 7 ,7 ,7, 7 ,7 ,7 ,7 ,7, 7 ,7, 7 ,7 ,7 ,7 ,7 ,7 ,7 ,7, 7, 7, 7, 7 ,7 ,7 ,7 ,7 ,7 ,7, 7, 7 ,7 ,7 ,7 ,7 ,7 ,7 ,7 ,7, 7, 7, 7 ,7 ,7, 7 ,6, 6, 6, 6, 6 ,6 ,6, 6, 6 ,6 ,6, 6, 6 ,6, 6, 6 ,6, 6 ,6 ,6 }; So basicly this is a 10*10 Every number is a placeholder for a image(number).png But how do i merge them together? //Simon Okay so the following

Android Canvas Drawing Text and Change Text afterwards

房东的猫 提交于 2019-12-02 01:45:28
问题 I´ve created a costum view, and on the onDrawMethod i´ve started to draw some things. A few rects,lines, and a text. canvas.drawText("Hello",150,150, paint); Now, I want to change this text, after an OnTouchEvent. My problem is, that I don´t know, how to remove the old text. At the moment my second text, which is shown after the TouchEvent, is just overlapping my old text. Should I redraw my hole view with the new text? 回答1: Typically you would redraw the entire view if a lot of things are

Android: How do I scale a bitmap to fit the screen size using canvas/draw bitmap?

我与影子孤独终老i 提交于 2019-12-02 01:31:24
I am taking an image and drawing it to the screen using canvas. I want to scale it based on the screen size. This is what I tried, but it cuts off a large chunk of the image: DisplayMetrics metrics = context.getResources().getDisplayMetrics(); int width = metrics.widthPixels; int height = metrics.heightPixels; Bitmap bitmap = BitmapFactory.decodeResource(context.getResources(),R.drawable.myimage); bitmap = Bitmap.createScaledBitmap(bitmap, width, height, false); Rect frameToDraw = new Rect(0, 0, width, height); RectF whereToDraw = new RectF(0, 0, width, height); canvas.drawBitmap(bitmap

left drawable alignment with text in android

这一生的挚爱 提交于 2019-12-02 01:15:19
I am new to custom view and didn't know much about canvas in android, I wanted to align a left drawable to right side of layout along with the text(whether multiline or not) of same textview as in this image In the above image, i wanted to align $ image along with text($20.0 -$90.0 /hour) and must be in center if text is multiline and i don't want to use any extra layouts. Thanks in advance This is my basic xml, <RelativeLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_gravity="center""> <TextView android:id="@+id/ad_post_tv_noDays" style="@style