android-drawable

Can a drawable shape have it's size set to fill_parent?

陌路散爱 提交于 2019-12-06 16:36:32
问题 Is it valid for a drawable shape in Android to use fill_parent for it's size? <shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="oval"> <solid android:color="#666666"/> <size android:width="fill_parent" android:height="fill_parent"/> </shape> EDIT This for the background of ImageButton views. I want the icon for the button to have a circle behind it, but I don't always know what the size of the button will be (different sizes per layout). 回答1: Not really. Not

How to set a shape's background in xml?

为君一笑 提交于 2019-12-06 16:30:40
问题 I just created a red circle using android shapes: <?xml version="1.0" encoding="utf-8"?> <shape xmlns:android="http://schemas.android.com/apk/res/android" android:innerRadiusRatio="4" android:shape="ring" android:thicknessRatio="9" android:useLevel="false" > <solid android:color="#FF0000" /> <size android:height="48dip" android:width="48dip" /> </shape> This is really cool, but I cannot set the background color of the circle to my color. I tried android:background="#FFFFFF" but it always

Getting black ImageView using Picasso and Glide

喜欢而已 提交于 2019-12-06 16:30:02
问题 The problem I'm writing an Android app that's supposed to have a "Slideshow" feature on it. I've found this nice library, based on Picasso, that does exactly what I wanted, and it worked just fine most of the times. Problem is, sometimes my images are not loaded into the slide ImageView ... It only shows a "black canvas" as you can see on the screenshot below. I am loading the image from a local resource from my drawables. Sometimes it happens on Portrait mode, sometimes on Landscape mode. It

error: too many padding sections on right border

不打扰是莪最后的温柔 提交于 2019-12-06 15:13:57
when i build my project it give me error like I found the reason that, because of 9 patch file i am getting this error. so can any one please look at this 9-patch file for whats wrong in this below image. also i am using layer list for this drop down which is below drop_down_drawable.xml <?xml version="1.0" encoding="utf-8"?> <layer-list xmlns:android="http://schemas.android.com/apk/res/android"> <item> <shape android:shape="rectangle"> <corners android:radius="2dp" /> <stroke android:width="1dp" android:color="@color/black_c4c4c4" /> </shape> </item> <item android:bottom="@dimen/margin_8"

ViewGroupOverlay doesn't show view

余生颓废 提交于 2019-12-06 11:55:25
I'm currently trying to create a puzzle game where I have a grid and each cell should be able to show a visual (and only visual) indication on touch. Therefore, I intent to use the ViewGroupOverlay (with getOverlay()) with a custom view: In each CellView @Override public boolean onTouchEvent(MotionEvent event) { if(event.getAction() == MotionEvent.ACTION_DOWN) { LayoutInflater inflater = (LayoutInflater) getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE); View myView = inflater.inflate(R.layout.overlay, null); gridView.getOverlay().add(myView); } if(event.getAction() == MotionEvent

Android: How to make a drawable with a multicolor gradient?

一个人想着一个人 提交于 2019-12-06 10:31:59
I made this: ShapeDrawable.ShaderFactory shaderFactory = new ShapeDrawable.ShaderFactory() { @Override public Shader resize(int width, int height) { LinearGradient linearGradient = new LinearGradient(0, 0, width, height, new int[]{ 0xF44336, 0xFFB74D, 0xFFE082, 0xAED581, 0x4CAF50, 0xAED581, 0xFFE082, 0xFFB74D, 0xF44336}, new float[]{ 0, 0.125f, 0.25f, 0.375f, 0.5f, 0.625f, 0.75f, 0.875f, 1.0f}, Shader.TileMode.REPEAT); return linearGradient; } }; PaintDrawable paint = new PaintDrawable(); paint.setShape(new RectShape()); paint.setShaderFactory(shaderFactory); But I can't see anything when I

Draw custom drawable shape in android

夙愿已清 提交于 2019-12-06 09:04:34
I want to draw a custom shape in xml layout like below : I tried to do some code in XML but i do not understand how to give shadow effect to outline of this shadow. What i did : <?xml version="1.0" encoding="utf-8"?> <layer-list xmlns:android="http://schemas.android.com/apk/res/android"> <item android:width="20dp" android:height="20dp" android:gravity="top|left"> <rotate android:fromDegrees="45" android:pivotX="50%" android:pivotY="50%" android:toDegrees="45"> <shape android:shape="rectangle"> <corners android:bottomRightRadius="2dp"/> <gradient android:type="linear" android:angle="270"

Use custom selector for parent item and children items in ExpandableListView

扶醉桌前 提交于 2019-12-06 07:47:14
I have expandable list which looks like this: Orange items are children and are shown when you press specific parent. Blue items are parents.I used this custom adapter to create this: (I picked this source code somewhere here on forum) public class ExpandableListAdapter extends BaseExpandableListAdapter { private Context context; private List<String> listDataHeader; private HashMap<String, List<String>> listDataChild; public ExpandableListAdapter(Context context, List<String> listDataHeader, HashMap<String, List<String>> listChildData) { this.context = context; this.listDataHeader =

How to implement a badge counter on android hamburger menu icon [duplicate]

感情迁移 提交于 2019-12-06 07:43:36
问题 This question already has answers here : Add new item count to icon on button - Android (5 answers) Closed 3 years ago . I am trying to implement a counter badge on the hamburger menu icon (i.e. not the other menu icons). Similar to the eBay app. as in.. Has anyone looked into this? Trying to figure out the cleanest way possible. 回答1: its pretty simple to do with the Toolbar Widget you could follow below example to achieve that: first create an Oval shape <shape xmlns:android="http://schemas

android: Universal Image Loader get drawable from string array

亡梦爱人 提交于 2019-12-06 07:41:29
问题 Mostly I found like this on Internet public static final String[] imageurl = new String[] { "http://sample.com/sample1.png", "http://sample.com/sample1.png" }; So when loading image we just need to call imageloader.displayImage(imageurl[position], imageView, options); MY QUESTION I have string array inside arrays.xml <string-array name="sample" > <item>image1</item> <item>image2</item> <item>image3</item> <item>image4</item> </string-array> Then I'm trying to read sample string array inside