android-drawable

Create shape for drawable

谁说我不能喝 提交于 2019-12-12 10:08:11
问题 I have ListView , and i have a background for the list items: Is there any way to recreate this background as a shape in drawable XML? The most outer grey is not part of the item background, it is actually the ListView . 回答1: You can try following with the values of your choice. It will make the bottom two corners rounded. rounded_rectangle.xml <?xml version="1.0" encoding="utf-8"?> <selector xmlns:android="http://schemas.android.com/apk/res/android"> <item> <shape> <gradient android:angle=

Android circular progress bar with rounded corners

北战南征 提交于 2019-12-12 07:13:02
问题 I am trying to get a circular progress bar with rounded corner as shown below. But I am not able to get the rounded corner so far I am able to get the circular progress bar. I am trying to draw it using the xml drawable. <ProgressBar android:id="@+id/onboarding_activity_progress_bar" android:layout_gravity="center" android:padding="10dp" android:layout_width="120dp" android:layout_height="120dp" style="?android:attr/progressBarStyleHorizontal" android:progressDrawable="@drawable/progressbar

Android drawables : Is there any way to somehow link the int IDs to the R drawable IDs?

僤鯓⒐⒋嵵緔 提交于 2019-12-12 04:13:07
问题 I have 718 drawables in the drawable-mdpi , drawable-hdpi and drawable-xhdpi folders, whose names are 1.png, 2.png... to 718.png. (They are actually Pokémon sprites) So, depending on the Pokémon, I want to load one of them to show it. However, I cannot use the number to directly identify the R drawable ID. Is there any way (besides of a 718-case switch or a Hashmap<Integer,Integer> ) to somehow link the int IDs to the R drawable IDs? 回答1: You could try: String sprite = "drawable/"+number; int

Draw bubble programmatically with arrow

你。 提交于 2019-12-12 03:37:22
问题 I am implementing the following Class from Stackoverflow https://stackoverflow.com/a/20811323/1936925 but I need a bubble like this I am trying a lot, but don't know how to do it. What edits do I need to do in order to get the above drawable. 回答1: Try this: public Bitmap overlay(Bitmap image, String content) { BitmapFactory.Options options = new BitmapFactory.Options(); options.inScaled = false; options.inPreferredConfig = Bitmap.Config.ARGB_8888; //My bg bitmap, use yours Bitmap background =

Trying to get drawable resource ID from its name in Android

北城余情 提交于 2019-12-12 03:27:00
问题 I have a resource file like this: strings.xml <string name="category01">My Category 01</string> <string name="category02">My Category 02</string> <string name="category03">My Category 03</string> <string-array name="array_category_01"> <item name="title">@string/category01</item> <item name="image">@drawable/img01</item> </string-array> <string-array name="array_category_02"> <item name="title">@string/category02</item> <item name="image">@drawable/img02</item> </string-array> <string-array

Multi color Stroke image with XML

我与影子孤独终老i 提交于 2019-12-12 03:23:30
问题 Does it possible to create multi-color stroke with the help of XML? I want to create exact view attached here. Thanks 回答1: You could use a trick by creating a drawable shape with gradient and make it a parent's background... something like this: gradient_stroke.xml (in res/drawable): <?xml version="1.0" encoding="utf-8"?> <selector xmlns:android="http://schemas.android.com/apk/res/android"> <item> <shape android:shape="rectangle" > <gradient android:angle="180" android:startColor="#fff96200"

Android: how to create shape with skewed two-tone color?

房东的猫 提交于 2019-12-12 02:31:42
问题 I am attempting to create a drawable shape that will become the background of a search bar. I know how to create a rectangle with two colors but I do not know how to tilt the color at an angle, like in the second image. Can someone help me with this? Thanks. 回答1: Take a Toolbar...code is here... <android.support.v7.widget.Toolbar android:layout_width="500dp" android:layout_height="wrap_content" android:background="@drawable/custom_background" /> create a drawable res file custom_background

Create Drawable at Runtime and add into Resources

纵然是瞬间 提交于 2019-12-12 02:08:41
问题 I create Drawable for my Android application at runtime. These Drawables are generated from font icon FontAwesome. I'm searching a way to add these drawables into Resources of my Android project. I would like to generate drawables at start of the application and use them in the rest of the application by accessing through resources. Is it possible to add a drawable object into project resources in Java code? 回答1: You can't add a drawable to your project resources at runtime. These are

Animating 3 parts of a view

别来无恙 提交于 2019-12-12 02:05:18
问题 I am trying to make an app view that, when presented with a subtraction problem, will show an animation of a growing rectangle (or fat line) that crawls up the number line to that integer. I already have things set up so that I click "show me!" and bars are drawn along the number line showing the minuend, the subtrahend and the difference, but I'd like to be able to have a positive number's rectangle crawl up in a positive direction, negative from zero in the negative direction. In looking

Andorid DrawPath doesn't fill-up the enclosed area

為{幸葍}努か 提交于 2019-12-12 01:45:20
问题 Following list shows the x,y coordinates and particular method used to create a Path. 0 0 moveTO 180 0 lineTo 180 0 moveTO 246 227, 127 24, 115 150 cubicTo 127 276, 246 71, 180 300 cubicTo 180 300 moveTO 44 261, 166 332, 90 339 cubicTo 14 332, 136 261, 0 300 cubicTo 0 300 moveTO 0 0 lineTo Raw data points x = [0, 180, 180, 246, 127, 115, 127, 246, 180, 180, 44, 166, 90, 14, 136, 0, 0, 0] y = [0, 0, 0, 227, 24, 150, 276, 71, 300, 300, 261, 332, 339, 332, 261, 300, 300, 0] Idea of this algo is