android-drawable

android create pie dount with gradient

血红的双手。 提交于 2019-12-03 00:42:11
Is there any way to create circle with gradient like this ? As far as i get is this: <shape android:innerRadiusRatio="3" android:thicknessRatio="10" android:shape="ring"> <gradient android:endColor="@color/cyan_dark" android:startColor="@color/red" android:type="radial" android:gradientRadius="340" android:centerX="50%" android:centerY="0" /> </shape> XML <ProgressBar android:id="@+id/yourId" style="?android:attr/progressBarStyleHorizontal" android:layout_width="89dp" android:layout_height="89dp" android:layout_centerHorizontal="true" android:layout_centerVertical="true" android:max="100"

Using layer-list to display some drawable images

梦想与她 提交于 2019-12-02 18:57:07
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 AVD and Nexus 5. As you can see there is no problem. <layer-list xmlns:android="http://schemas.android

how to get android gradient center light effect?

╄→гoц情女王★ 提交于 2019-12-02 18:49:34
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> Make a new Android xml file (say GreyRadial.xml) file in your drawable folder In your xml file <?xml version="1.0" encoding="utf-8"?> <shape xmlns:android="http://schemas.android.com

Centering bitmap Marker (Google Maps Android API v2)

别来无恙 提交于 2019-12-02 18:42:00
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() == 0) { p.color(0xFF000000); m = null; } else if (tr.getCapacidad() - tr.getPlazasOcupadas() == 0) { p

Custom Button Background with diagonal Cutting View

半城伤御伤魂 提交于 2019-12-02 18:25:57
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. 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 xmlns:android="http://schemas.android.com/apk/res/android" android:width="150dp" android:height="80dp"

How to get the drawable from relative layout in android

。_饼干妹妹 提交于 2019-12-02 18:21:46
问题 What i have done: I have set the bitmap for a relative layout as below RelativeLayout root; root= (RelativeLayout) itemView.findViewById(R.id.root); BitmapFactory.Options options = new BitmapFactory.Options(); options.inSampleSize = 4; Bitmap preview_bitmap = BitmapFactory.decodeResource(context.getResources(),godImages[position], options); Drawable drawable = new BitmapDrawable(context.getResources(),preview_bitmap); root.setBackgroundDrawable(drawable); What i am trying to do: I am trying

How to create a right facing arrow (chevron) using XML shapes in android? [closed]

可紊 提交于 2019-12-02 17:10:45
How to create a right facing arrow using xml shapes in android like this?? I've had a similar problem. Here's how I solved it: <layer-list xmlns:android="http://schemas.android.com/apk/res/android" > <item> <shape> <solid android:color="@android:color/transparent"/> <size android:width="2dp" android:height="50dp"/> </shape> </item> <item android:bottom="20dp"> <rotate android:fromDegrees="-45" android:toDegrees="45"> <shape android:shape="rectangle"> <solid android:color="@android:color/black"/> <corners android:radius="1dp" android:bottomRightRadius="0dp" android:bottomLeftRadius="0dp"/> <

Create a new color drawable

随声附和 提交于 2019-12-02 16:28:24
I am trying to convert a hex value to an int so I can create a new color drawable. I'm not sure if this is possible, but according to the documentation , it should. It plainly asks for public ColorDrawable (int color) Added in API level 1 Creates a new ColorDrawable with the specified color. Parameters color The color to draw. So, my code isn't working because I'm getting an Invalid int: "FF6666" error. Any ideas? int decode = Integer.decode("FF6666"); ColorDrawable colorDrawable = new ColorDrawable(decode); Since you're talking about hex you have to start with 0x and don't forget the opacity.

Adding bottom margin to ListView last element

眉间皱痕 提交于 2019-12-02 14:48:08
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 ListView. But footers are quite unstable things, they usually disappear after notifyDataSetChanged and

How to center vector drawable in layer-list without scaling

戏子无情 提交于 2019-12-02 14:34:45
I am attempting to use a VectorDrawable in a LayerList without scaling the vector. For example: <layer-list> <item android:drawable="@color/grid_item_activated"/> <item android:gravity="center" android:drawable="@drawable/ic_check_white_48dp"/> </layer-list> The drawable ic_check_white_48dp id defined as: <vector xmlns:android="http://schemas.android.com/apk/res/android" android:width="48dp" android:height="48dp" android:viewportWidth="24.0" android:viewportHeight="24.0"> <path android:fillColor="#FFFFFFFF" android:pathData="M9,16.17L4.83,12l-1.42,1.41L9,19 21,7l-1.41,-1.41z"/> </vector> The