android-drawable

Android: Change center of linear GradientDrawable via code

谁都会走 提交于 2019-11-29 15:30:47
EDIT: LOOK AT SOLUTION ABOVE i m freaking out. all i just want to do, is setting a linear GradientDrawable, which changes the vertical center of the gradient... drawing the gradient works fine, but how can i change the center of it?!? RelativeLayout bgScreen = (RelativeLayout) findViewById(R.id.player_screen); GradientDrawable gd = new GradientDrawable( GradientDrawable.Orientation.TOP_BOTTOM, new int[] {startColor,endColor}); gd.setCornerRadius(0f); gd.setAlpha(200); bgScreen.setBackground(gd); public void redrawOrChangeBackgroundGradient(){ //??? either change center of existing gd

Android EditText draw a divider line between its drawable and its text

风流意气都作罢 提交于 2019-11-29 12:36:15
问题 I have an EditText with a drawableLeft image. I need to add a vertical line in EditText right beside my drawableLeft like this example: Easiest way that I can think of is to add that line into my drawable image. But generally is there any other way to do this? 回答1: Create a rectangular rounded corner shape in res/drawable/shape.xml <?xml version="1.0" encoding="utf-8"?> <shape xmlns:android="http://schemas.android.com/apk/res/android"> <stroke android:width="3dip" android:color="@android

Not able to understand how to use different density images for 1.6+?

雨燕双飞 提交于 2019-11-29 10:23:41
问题 I'm trying to understand how the res/drawables images should work with different screen densities. Right now I've got a 1.5 app, and for example, I have an image that is 100x100 pixels. When used on the Droid, it scales this image so it appears to be the same size relatively on that device (all other layout scaling is handled by me, using dip units). So now I need to update my project and add three folders, right?: drawable-ldpi drawable-mdpi drawable-hdpi so I'm going to put my 100x100 image

Creating a drawable & zoomable image view in android

Deadly 提交于 2019-11-29 05:54:04
问题 Goal: Create an imageview that is drawable and zoomable, That means when I press a button to on , it is drawable, or when I turn off, that is zoomable. *Notice the drawings should zoom align with the imageview =============================================================== Recently I wrote a custom drawable image view like this: public class DrawView extends ImageView { private int color = Color.BLACK; private float width = 4f; private List<Holder> holderList = new ArrayList<Holder>();

Android receipt/zigzag drawable/layout

五迷三道 提交于 2019-11-29 03:21:43
问题 I'm in need of creating a receipt layout in Android. The idea is very simple, a rectangle layout with a zigzag bottom edge. The best result would be a drawable/layout with a fixed zigzag size (meaning, fixed half-triangle size), which will multiply the amount of triangles according to the shape's actual width, in real time. With a clip maybe, to have clipped triangles if necessary. Here is a good example ( edit : I'm referring to the bottom zigzag line) : I actually have no solid idea of how

Usage of mipmap launcher icons before Android 4.2?

你。 提交于 2019-11-29 03:04:18
I'm using Android Asset Studio to generate my launcher icon and I've seen that the output is now creating mipmap folders instead of drawable folders. Since mipmap support has been added since Android 4.2 and my application is targeting ICS 4.0.3 (API 15). Is it safe to use them ? and then don't have any ic_launcher icon in drawables folders ? update I confirm it's working fine. You can only use mipmap folders for Application icon Mipmap folder support was added in Android SDK 11 or Honeycomb. This means that you can use the Mipmap folder from Android version 3.0 and above, including version 4

How rotate line in Android XML?

房东的猫 提交于 2019-11-28 23:20:17
I'm trying to draw a diagonal line in an Android app with the XML, but it is not working. It simply draws a horizontal line. main.xml : <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:paddingBottom="@dimen/activity_vertical_margin" android:paddingLeft="@dimen/activity_horizontal_margin" android:paddingRight="@dimen/activity_horizontal_margin" android:paddingTop="@dimen/activity_vertical_margin" tools:context=".TestActivity" > <RelativeLayout

Create a custom background drawable for a EditText

孤者浪人 提交于 2019-11-28 16:32:23
问题 I'm trying to set a custom drawable to a EditText as expected below: So I wrote this custom drawable: <?xml version="1.0" encoding="utf-8"?> <layer-list xmlns:android="http://schemas.android.com/apk/res/android" android:paddingBottom="12dp" android:paddingLeft="36dp" android:paddingRight="12dp" android:paddingTop="12dp"> <item> <shape> <corners android:radius="6dp"/> <solid android:color="@android:color/white"/> <stroke android:width="1dp" android:color="#BBBBBB"/> </shape> </item> <item

Material design suggestions for lists with avatar, text and icon

别说谁变了你拦得住时间么 提交于 2019-11-28 15:18:28
I want to create Material Designed Android application and I try to follow all Google's suggestions about making nice layouts specially for the new RecylcerView . The RecyclerView has avatar ImageView , title and subtitle TextView and action icon ImageView . What values should I put in ImageView's properites for width and height so it supports different screen sizes and densities, and what size of those drawables should I choose from the system icons pack? material-design-icons-1.0.1 Suggestion for lists: ??? in xml code are the unknown things I don't know what to put there: XML: <?xml version

Bitmap and outOfMemory in android

风格不统一 提交于 2019-11-28 14:53:12
I have problem with out of memory with my bitmap. This is code: Uri bitmapPictureUri = intent.getParcelableExtra(TaskActivity.PHOTO); Bitmap bitmap = null; try { bitmap = MediaStore.Images.Media.getBitmap(this.getContentResolver(), bitmapPictureUri); } catch (FileNotFoundException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } int nh = (int) (bitmap.getHeight() * (512.0 / bitmap.getWidth())); bitmapPicture = Bitmap.createScaledBitmap(bitmap, 512, nh, true); picture.setImageBitmap(bitmapPicture);