android-drawable

Draw triangle background in android

﹥>﹥吖頭↗ 提交于 2019-12-03 06:36:50
I need to draw a background of layout as a triangle, like you can see in the picture. I've found an example where they do something similar, but I don't know how to adapt it to my case. Here is the example Can anyone help me? Best. Here is an example of a drawable resource with a triangle in the right bottom corner in front of an image. As the image I used the default android launcher icon. You can use any other image. Create triangle.xml file in res/drawable like this: <layer-list xmlns:android="http://schemas.android.com/apk/res/android" > <item android:drawable="@drawable/ic_launcher"> <

how to get android gradient center light effect?

我与影子孤独终老i 提交于 2019-12-03 06:20:52
问题 i want something like following image i tried it using drawable shape <?xml version="1.0" encoding="utf-8"?> <shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle" > <gradient android:angle="360" android:centerX="50%" android:centerY="50%" android:gradientRadius="50%" android:endColor="#000000" android:centerColor="#FFFFFF" android:startColor="#000000" > </gradient> </shape> 回答1: Make a new Android xml file (say GreyRadial.xml) file in your drawable folder

Centering bitmap Marker (Google Maps Android API v2)

自闭症网瘾萝莉.ら 提交于 2019-12-03 06:11:37
问题 When I add a marker from a custom Bitmap, the marker is not centered at the point I specify. I'm adding it like this: // ID tramo final int tramoId = tr.getId(); // Nodos final Nodo[] nodos = tr.getNodos(); final PolylineOptions p = new PolylineOptions(); MarkerOptions m = new MarkerOptions(); // Seteamos posicion de linea y marker m.position(semisuma(nodos)); for (final Nodo n : nodos) { p.add(n.getLatLng()); } // Color de linea y marker BitmapDescriptor icon = null; if (tr.getCapacidad() ==

Android selector with fade in / fade out duration initially invisible

懵懂的女人 提交于 2019-12-03 06:02:08
I'm trying to achieve that an icon in ActionBar will not change states discretely, but by fading animation. When I add android:enterFadeDuration and android:exitFadeDuration to the selector tag, my drawable is initially invisible - when I tap it, it changes state to state_pressed (properly with enter fade duration) and when I release it, it turns back to its normal visible unselected state. I must be missing something obvious, or is this a bug of some kind? <?xml version="1.0" encoding="utf-8"?> <selector xmlns:android="http://schemas.android.com/apk/res/android" android:enterFadeDuration="150

Add shadow on right and bottom side of the layout

心已入冬 提交于 2019-12-03 05:36:30
I want to add a light shadow on the right and bottom side of the layout.I tried using android:background="@android:drawable/dialog_holo_light_frame" but it adds a thick shadow on all four sides of the layout.What drawable i need to create and set as background? <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="vertical" android:background="@android:drawable/dialog_holo_light_frame"> <ImageView android:id="@+id/g" android:layout_width="wrap_content" android:layout_height="wrap

Custom Button Background with diagonal Cutting View

a 夏天 提交于 2019-12-03 05:11:27
问题 I want to set background as shown in image i have tried many tutorial for example https://medium.com/@adinugroho/create-diagonal-cut-view-in-android-5a376eca6a1c https://github.com/florent37/DiagonalLayout but not getting proper result,can anyone help me to get perfect result. Thanks in Advance. 回答1: UPDATED ANSWER Please do note that you may need to tweak the width and height of the Button to make it work for you. You can do this with vector and layer-list drawables. diagonal_shape <vector

Why getDrawable() doesn't work on some Android devices?

元气小坏坏 提交于 2019-12-03 04:38:11
I am getting "nosuchmethod error" on some user's phones (eg. Motorola Razr i) but it works fine on my HTC. Below is the code. Drawable rBlack; rBlack = getResources().getDrawable(R.drawable.rblack, getTheme()); And the Stacktrace: java.lang.NoSuchMethodError: android.content.res.Resources.getDrawable at org.petero.droidfish.myClass.onCreate(myClass.java:434) at android.app.Activity.performCreate(Activity.java:5248) at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1110) at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2173) at android.app

Android nine patch - allow only a specific area of a background drawable to stretch

隐身守侯 提交于 2019-12-03 03:47:32
How does one go about creating a View that has boundaries with triangular perforations ? I've been using background drawables to achieve this so far. That works when the dimensions of the View are fixed. Now I have a situation where the height of the View is not constant, so I need to have the height variable on the fly. I can't use a background drawable with a fixed height anymore. Here is the original background drawable: And this is what the final View needs to look like: Another way of looking at the same problem is, can we allow the center of the image to stretch without distorting the

Reference drawable from string-array in android [duplicate]

一个人想着一个人 提交于 2019-12-03 01:26:54
This question already has an answer here: Storing R.drawable IDs in XML array 6 answers how would I reference a drawable resource from the string xml file? I want to do <string-array name="my_array"> <item>@drawable/my_image</item> ... How would I do that? for arrays of drawables ids, don't use string array just use <array> then to use them, get a TypedArray if the ids TypedArray images = getResources().obtainTypedArray(R.array.my_image_ids); int resourceId = images.getResourceId(id, -1); and don't forget when you're done with the resource id and array to recycle it images.recycle(); I guess

Adding bottom margin to ListView last element

﹥>﹥吖頭↗ 提交于 2019-12-03 01:25:27
问题 I need to add to add ListView with complicated items background: different for even/odd and rounded corners at the top and bottom. It looks like this: I have implemented all this stuff via level-list, but there is one more thing I want to do. Now the bottom item is near the bottom of the screen. It is better to add some space. I don't want to add bottom margin to ListView, I need margin only for last item. The ways I see to do this: Footer A kind of hack – add footer with empty TextView to