android-drawable

How to set a shape's background in xml?

拥有回忆 提交于 2019-12-04 23:37:46
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 appear to be black in my layout. How can I set the background of the above shape? I think a layer-list

Getting black ImageView using Picasso and Glide

夙愿已清 提交于 2019-12-04 22:12:39
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 doesn't matter which image I use, sometimes that "blackness" happens. EDIT: I'm using Android 5.0.2

how to use drawable to compatible with all screen sizes (idpi, mdpi, hdpi, xhdpi, xxhdpi)

妖精的绣舞 提交于 2019-12-04 21:35:11
Hello I am new in android programing so I want to know: How to use drawable to compatible with all screen sizes (idpi, mdpi, hdpi, xhdpi, xxhdpi) Actually I am confused about drawable screen sizes compatibility with all screen sizes so I want to know that: If I want my app to compatible with all screen size do I need to put images in every drawable folder for example: background image • drawable-ldpi ( 240x320 for QVGA Device 2.7 ) put image with this resolution • drawable-mdpi ( 320x480 for HVGA Device 3.2 ) put image with this resolution • drawable-hdpi ( 480x800 for WVGA Device 4.0 ) put

Changing color of single drawable in RecyclerView will change all drawables

百般思念 提交于 2019-12-04 19:33:38
问题 I just tried to change the color of my drawable inside my row depending on a value but instead of one drawable the adapter changed all of them. Here is my Adapter: public class ReportAdapter extends RecyclerView.Adapter<ReportAdapter.ReportViewHolder> { DataBaseHelper dataBase; private LayoutInflater inflater; List<ChoosedSubject> data = Collections.emptyList(); Context context; OnItemClickListener itemClickListener; public ReportAdapter(Context context, List<ChoosedSubject> data,

Android L is ignoring shapes as drawable background

对着背影说爱祢 提交于 2019-12-04 17:31:27
问题 I'm testing Android L Preview on my Nexus 5. I've got problem with my app. I've got some TextViews with background set: android:background="@drawable/rounded_textview" And "rounded_textview" is just shape. It is working great below <=API19. <?xml version="1.0" encoding="utf-8"?> <shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle" android:padding="3dp"> <solid android:color="#999999"/> <corners android:bottomRightRadius="2dp" android:bottomLeftRadius=

android: Universal Image Loader get drawable from string array

▼魔方 西西 提交于 2019-12-04 13:49:44
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 arrays.xml .... ArrayList<Integer> list = new ArrayList<Integer>(); .... final Resources resources =

Android enlarge center color with gradient

前提是你 提交于 2019-12-04 12:41:22
问题 I can not enlarge the width of a centeral color with a gradient. The goal is: Larger center with some color, and transparent on sides. Usage: <ImageView android:layout_width="match_parent" android:layout_height="5dp" android:src="@drawable/gradient_normal"/> I tried many combinations with layer-list , but the result was not nice. One solution can be divide Layout to 50%-50% and set the first gradient from left to right (from transparent to color) and second right to left (from color to

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

倾然丶 夕夏残阳落幕 提交于 2019-12-04 12:06:23
This question already has an answer here: Add new item count to icon on button - Android 5 answers 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. 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.com/apk/res/android" android:shape="oval"> <solid android:color="#ff00"/> </shape> then create a toolbar widget as below:

Draw triangle background in android

≯℡__Kan透↙ 提交于 2019-12-04 10:46:34
问题 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. 回答1: 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 selector with fade in / fade out duration initially invisible

旧街凉风 提交于 2019-12-04 10:29:51
问题 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