drawable

How to support all the different resolutions of android products

你离开我真会死。 提交于 2019-11-27 13:17:55
All the different resolutions of the different Android products are driving me nuts. My first android app that I wrote was designed so it supported the three commonly used resolutions: 240x320 (LDPI), 320x480 (MDPI) and 480x800 (HDPI). The 480x854 didn't do any harm to the layout because it has the same width as 480x800. I've also bought the following devices to test my android apps on: Samsung Galaxy Europe (LDPI) HTC Desire Z (HDPI) Luckily my girlfriend has a HTC Wildfire S (MDPI) so I've got most resolutions covered. But today, my brother downloaded my app on his new HTC Sensation which

Resize Drawable in Android

好久不见. 提交于 2019-11-27 11:54:48
I am setting a drawable for a progress dialog ( pbarDialog ) but my issue is I want to resize the drawable each time but can't figure out how. Here is some code: Handler progressHandler = new Handler() { public void handleMessage(Message msg) { switch (msg.what) { // some more code case UPDATE_PBAR: pbarDialog.setIcon(mAppIcon); pbarDialog.setMessage(mPbarMsg); pbarDialog.incrementProgressBy(mIncrement+1); break; } } }; pbarDialog.show(); Thread myThread = new Thread(new Runnable() { public void run() { // some code for (int i = 0; i < mApps.size(); i++) { mAppIcon = mAdapter.getIcons().get

Half circle shape not work

会有一股神秘感。 提交于 2019-11-27 11:41:41
I try to create half circle background, in development IDE preview it works, but when I launch in emulator it doesn't work. Here is my shape code : <?xml version="1.0" encoding="utf-8"?> <layer-list xmlns:android="http://schemas.android.com/apk/res/android"> <item android:height="50dp"> <shape> <solid android:color="@color/colorAccentDark" /> </shape> </item> <item android:top="-500dp" android:bottom="0dp" android:left="-100dp" android:right="-100dp"> <shape> <corners android:radius="500dp" /> <solid android:color="@color/colorAccentDark" /> </shape> </item> </layer-list> And here is my layout

Change background of EditText's error message

半世苍凉 提交于 2019-11-27 11:34:27
What I want to do is change the background color (set custom drawable) of a popup error message displayed after using setError() method. Currently, it looks like this: I've found that Android has two files: popup_inline_error.9.png popup_inline_above_error.9.png And you're supposed to be able to set them using two attributes: errorMessageBackground errorMessageAboveBackground But when I try to set them in my theme, all I get is: <item name="errorMessageBackground">@drawable/popup_inline_error_holo_light</item> <item name="errorMessageAboveBackground">@drawable/popup_inline_error_above_holo

How to draw text on canvas?

╄→гoц情女王★ 提交于 2019-11-27 11:33:23
问题 i'm trying to develop a simple pie chart class for android. For now, it can take a map of labels and values and draw the pie chart. I'm yet to add the legends for the pie, which is where i need to place the texts near small rectangles on the screen corner. Any help appreciated, since i'm new to Android dev. 回答1: You will have to use the drawText method of the Canvas class. Paint paint = new Paint(); canvas.drawPaint(paint); paint.setColor(Color.BLACK); paint.setTextSize(16); canvas.drawText(

Only use XHDPI drawables in Android app?

自作多情 提交于 2019-11-27 11:26:19
If you're planning to support LDPI, MDPI, HPDI, and perhaps XHDPI in the near future, is it ok to only include XHDPI drawables in the project and let the devices scale them to their desired resolution? I've tested to resize the drawables into MDPI and HDPI in Photoshop and then compared the result with XHDPI drawables only resized by Android, and I can't see any difference at all. Is it bad design to take this shortcut? It would be nice to not have to resize each and every drawable into 3 different resolutions. Planning to use target SDK is 2.1 or 2.2. BR Emil I guess that's a good way to go.

android RadioButton button drawable gravity

本秂侑毒 提交于 2019-11-27 11:22:42
I am generating RadioButtons dynamically with RadioButton radioButton=new RadioButton(context); LayoutParams layoutParams=new LayoutParams(radioWidth,radioHeight); layoutParams.gravity=Gravity.CENTER; radioButton.setLayoutParams(layoutParams); radioButton.setGravity(Gravity.CENTER); BitmapDrawable bitmap = ((BitmapDrawable)drawableResource); bitmap.setGravity(Gravity.CENTER); radioButton.setBackgroundDrawable(getResources().getDrawable(R.drawable.itabs_radio)); radioButton.setButtonDrawable(bitmap); as you can see I am desperately trying to set gravity of button drawable to center, but without

Android: How to check if a path contains touched point?

巧了我就是萌 提交于 2019-11-27 11:15:41
i would try to develop an application in which i can draw a planimetry. So, each room has got its own ID or name and, if i touch a room, i want to show a Toast Message with that ID or name. The problem is how check if and which path is touched!! I saw a lot of topic discussions that talked about this problem. Someone says to use getBounds method and, after, contains method for checking if touched point is in Rect. But, i guess getBounds method returns the smallest Rect that contains path, right? So, rooms have different custom geometric forms and, for this reason, if i get bounds about 2 close

Styling EditText view with shape drawable to look similar to new holographic theme for Android < 3.0

|▌冷眼眸甩不掉的悲伤 提交于 2019-11-27 11:15:34
I want to create a shape drawable for that mimics the new holographic theme (Android >=3.0) on older Android versions. It's quite easy to draw a line at the bottom with <?xml version="1.0" encoding="utf-8"?> <layer-list xmlns:android="http://schemas.android.com/apk/res/android" > <item> <shape > <solid android:color="@color/border" /> </shape> </item> <!-- main color --> <item android:bottom="1.5dp"> <shape > <solid android:color="@color/background" /> </shape> </item> </layer-list> But how to draw the tick boundaries left and right as in the holo theme Entreco It's a little hack, but unless

Android: failed to convert @drawable/picture into a drawable

≯℡__Kan透↙ 提交于 2019-11-27 11:09:44
In my drawable folder I have a few images and they all reference perfect, but when I try and add any more images with the exact same size in the same folder, and try to reference it, is flags up an error "Failed to convert @drawable/picture into a drawable" . I have tried the same image with a different name and it just keeps giving me that error. I have also tried it in a different XML layout and the same thing. Also the name of the picture have been "jack", "abc", "question_mark" as you can see there are strictly in the rules of the what characters you can use, and still the error message