drawable

How to add XML drawable in Eclipse

僤鯓⒐⒋嵵緔 提交于 2020-01-29 05:18:08
问题 Ok guys I'm little stacked here. According to official documentation Google says that "Once you've defined your Drawable in XML, save the file in the res/drawable/ directory of your project." is the way to add a XML drawable to the project. But when I created the project ADT created 3 different drawable folders for mdpi, hdpi, and ldpi. So when I wanted to create my XML drawable, I right click on my drawable-hdpi folder and select "Add new Android XML file", and there I have to select what

Is there any reason to preloading drawables from resources?

寵の児 提交于 2020-01-22 18:44:05
问题 Does Android maintain a memory cache of application drawable resources and reuse them, or it is a good practice to preload all drawables that may be assigned dynamically to different widgets? For instance: public static final int[] SETS = { R.drawable.set0, R.drawable.set1, R.drawable.set2, R.drawable.set3, R.drawable.set4, R.drawable.set5, R.drawable.set6, R.drawable.set7, R.drawable.set8, R.drawable.set9, R.drawable.set10}; public Drawable[] sets; void init() { load(sets, SETS); } public

Using layer-list to display some drawable images

笑着哭i 提交于 2020-01-22 05:11:26
问题 Android studio 2.0 Preview 3b Hello, I have created the following layout that I want to use for a background for my app. I am using the layer-list and I want to display a bowl of peas in 2 locations. Everything looks ok in the preview, but when I run on genymotion or some cheap Chinese devices the image stretches across the screen. However, on the Android AVD, everything looks fine and on my Nexus 5 (real device) everything works ok. This is what I want and this is how it's displayed in the

android triangle drawablw xml

こ雲淡風輕ζ 提交于 2020-01-21 12:24:50
问题 I want to draw an equilateral triangle.I have checked but it is inverted.I want a triangle that looks like the image below. Triangle: triangle_shape.xml: <?xml version="1.0" encoding="utf-8"?> <layer-list xmlns:android="http://schemas.android.com/apk/res/android" > <item> <rotate android:fromDegrees="45" android:toDegrees="45" android:pivotX="-40%" android:pivotY="87%" > <shape android:shape="rectangle" > <stroke android:color="#fff" android:width="1dp"/> <solid android:color="#000" /> <

android triangle drawablw xml

谁都会走 提交于 2020-01-21 12:24:07
问题 I want to draw an equilateral triangle.I have checked but it is inverted.I want a triangle that looks like the image below. Triangle: triangle_shape.xml: <?xml version="1.0" encoding="utf-8"?> <layer-list xmlns:android="http://schemas.android.com/apk/res/android" > <item> <rotate android:fromDegrees="45" android:toDegrees="45" android:pivotX="-40%" android:pivotY="87%" > <shape android:shape="rectangle" > <stroke android:color="#fff" android:width="1dp"/> <solid android:color="#000" /> <

problems with big drawable jpg image

冷暖自知 提交于 2020-01-16 19:45:07
问题 during a couple of days i've been looking here and on the Internet in many post for a solution on an issue im having loading or moving a large jpg image (located as a drawable reource by now) and I think it's time to ask myself altought there are many questions and solutions very related. I'm developing a 3D terrain simulation with OpenGL and the problem is that I'm using as terrain texture a quite large jpg image ( 2048x2048 = 1,94 MB ). Let's look at some workarround I Did: 1st: Bitmap

Strange drawing artefact using custom drawable with MapView

风流意气都作罢 提交于 2020-01-15 05:42:29
问题 I'm trying to add my own drawable and use it in a series of overlays on a MapView. The drawable is basically a rounded box with a black outline and a number in the middle. I have managed to achieve this using the code below, however there is what looks like a flag to the left of my box, which I certainly don't think I have drawn - so I'm wondering what it can be. This is an example of the image: Edit - this is what happens if a circle is drawn: My code is below: Custom Drawable: public class

How to place Compound drawable on top left of Text View

余生长醉 提交于 2020-01-14 09:45:53
问题 We can set compound drawables for textview as below using drawableLeft or setCompundDrawables but using this its only possible to place the drawable on left / right / top / bottom.But i want to put drawables only at top-left and top-right of the Textview. How can i do that ? 回答1: <?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" > <ImageView android:id="@+id

How can I add OnClickListener to Drawable in EditText?

我是研究僧i 提交于 2020-01-14 09:18:48
问题 I have edittext and want to add to right "search" icon.. searchTxt.setCompoundDrawablesWithIntrinsicBounds(0, 0, R.drawable.search, 0); But how can I add event for click this icon? searchTxt.setOnTouchListener(new OnTouchListener() { public boolean onTouch(View v, MotionEvent event) { Drawable co = ((TextView) v).getCompoundDrawables()[2]; if (event.getX() > v.getMeasuredWidth() - v.getPaddingRight() - co.getIntrinsicWidth()) { Datas.search = searchTxt.getText().toString(); startActivity

How can I add OnClickListener to Drawable in EditText?

北城以北 提交于 2020-01-14 09:18:22
问题 I have edittext and want to add to right "search" icon.. searchTxt.setCompoundDrawablesWithIntrinsicBounds(0, 0, R.drawable.search, 0); But how can I add event for click this icon? searchTxt.setOnTouchListener(new OnTouchListener() { public boolean onTouch(View v, MotionEvent event) { Drawable co = ((TextView) v).getCompoundDrawables()[2]; if (event.getX() > v.getMeasuredWidth() - v.getPaddingRight() - co.getIntrinsicWidth()) { Datas.search = searchTxt.getText().toString(); startActivity