android-drawable

Create a Shape dynamically

烈酒焚心 提交于 2019-12-10 04:04:45
问题 I have a shape object defined in XML like below: <shape android:shape="rectangle"> <gradient android:startColor="#333" android:centerColor="#DDD" android:endColor="#333"/> <stroke android:width="1dp" android:color="#FF333333" /> </shape> I want to create an equal object in my code. I created a GradientDrawable as below: gradientDrawable1.setColors(new int[] { 0x333, 0xDDD, 0x333 }); gradientDrawable1.setOrientation(Orientation.TOP_BOTTOM); But I don't know how to create a Stroke(?) and then

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

青春壹個敷衍的年華 提交于 2019-12-10 00:03:19
问题 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

Android: only use xxhdpi images

…衆ロ難τιáo~ 提交于 2019-12-09 14:36:38
问题 Is there any drawback in only using xxhdpi images and letting android scale the images? (Yes it might be more cpu intensive, but is it notable?) I tested it on a samsung s2 and the difference were small. Is there a restriction to only use this if set minSdk to XX, becaus there were no xxhdpi? 回答1: Here are a couple drawbacks I can think of: More CPU intensive to resize the images, the app will use more battery and might feel more sluggish, especially on older devices. The images that you are

How to change shape colors in Drawable?

旧巷老猫 提交于 2019-12-09 06:35:08
问题 I have the following button: <Button android:id="@+id/Button_Collect" android:layout_width="48dp" android:layout_height="48dp" android:layout_marginBottom="16dp" android:layout_gravity="center_horizontal" android:background="@drawable/CollectButtonShape" /> which looks like this: which consists of the following background drawable: <?xml version="1.0" encoding="utf-8"?> <layer-list xmlns:android="http://schemas.android.com/apk/res/android"> <item> <shape android:innerRadius="0dp" android

Add shadow on right and bottom side of the layout

两盒软妹~` 提交于 2019-12-09 05:17:18
问题 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

Converting an Integer to a Drawable

亡梦爱人 提交于 2019-12-08 14:20:31
问题 I have two Adapter classes and in the first one, i have an Array of Integers[] named mThumbIds which is initialized like this : // References to our images private Integer[] mThumbIds = { R.mipmap.beyondthe_ferocious_flash_majin_vegeta_icon, R.mipmap.full_tilt_kamehameha_super_saiyan2_gohan_youth_icon, R.mipmap.merciless_condemnation_goku_black_super_saiyan_rose_and_zamasu_icon, R.mipmap.everlasting_legend_super_saiyan_goku_icon, R.mipmap.indestructible_saiyan_evil_legendary_super_saiyan

Array of images stacked next to each other, using LayerDrawable.(Displaying multiple image in single imageview)

做~自己de王妃 提交于 2019-12-08 12:58:12
问题 I have 5 images, I need to display this horizontally spaced one after the other. Instead of using 5 different images to display these 5 images in a LinearLayout with horizontal orientation, I would like to use a single image view. With LayerDrawable can I achieve this? If yes how? All I want is to place images like in the sample below, where each of 'Querstions', 'Tags', 'Users', 'Badges', 'Unanswered' would be an image. 回答1: I found the answer, this is how I did each image is of dimension 48

java.lang.OutOfMemoryError: bitmap size exceeds VM budget on line Drawable.createFromStream(((java.io.InputStream) new URL(url), “”) in android

社会主义新天地 提交于 2019-12-08 09:23:36
问题 First I'm creating an Arraylist of images and image information by parsing json response `JSONArray jsonArray = jsonObj.getJSONArray("result"); for (int i = 0; i < jsonArray.length(); i++) { JSONObject jsonObjInner = jsonArray.getJSONObject(i); ImageInfo imageInfo = new ImageInfo(); imageInfo.setImageUrl("http://www.dvimaytech.com/markphoto/" + jsonObjInner.getString("image")); new GetDrawableFromUrl(imageInfo).execute(); imageInfo.setEmail(jsonObjInner.getString("emailid")); imageInfo

error: too many padding sections on right border

浪子不回头ぞ 提交于 2019-12-08 07:53:01
问题 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=

Different sized images (with the same name) in one drawable folder

懵懂的女人 提交于 2019-12-08 05:45:37
问题 I'm new to android programming and every single somewhat-similar question is from three or so years ago and doesn't really answer my question. Android Studio used to have different drawable folders for different dpi. Now there is only one. So if I have two images with the same name but for different dpi, where do I add them so that during runtime the phone can use the appropriate image? Also, most android phones now are xhdpi or xxhdpi--do I really need to include any images less than that?