drawable

Android drawable with background and gradient on the left

雨燕双飞 提交于 2019-12-19 03:18:10
问题 W would like to have a drawable which has background and gradient on the left that is about 10dp wide. Image of what I would like to achieve: Red gradient on the left Background on the rest How I can achieve that? I've tried layer-list with two shapes but with no luck. Item background: <layer-list xmlns:android="http://schemas.android.com/apk/res/android" > <item android:drawable="@drawable/background" /> <item android:drawable="@drawable/gradient" /> </layer-list> Background drawable: <shape

Android openRawResource() not working for a drawable

混江龙づ霸主 提交于 2019-12-18 20:29:28
问题 I'm trying to create an input stream by doing this InputStream is = (InputStream) getResources().openRawResource(R.drawable.image1); but I'm met with the error "Expected resource of type raw" with respect to my drawable file (R.drawable.image1). image1 is a png and in my res/drawable folder. Any ideas??? 回答1: @Broatian I don't currently have a res/raw folder. I found an alternative solution: is = context.getResources().openRawResource(+ R.drawable.image1); The + shows additional folders.

Using Smallest Width configuration qualifier

时光怂恿深爱的人放手 提交于 2019-12-18 17:56:03
问题 Is it valid to use drawable-swdp- like drawable-sw720dp-xhdpi? Below is my scenario: My Acer iconia tab A501 (10") has a resolution of 1280x800 and density mdpi(160dp). It is expected to take the resource from drawable-sw720dp-mdpi. But the resource is being taken from drawable-sw720dp-xhdpi. I have following folders: drawable-sw720dp drawable-sw720dp-mdpi drawable-sw720dp-hdpi drawable-sw720dp-xhdpi is this the way this qualifier is to be used? or Is the density already considered while

Android Selector Drawable doesnt work with attributes

别来无恙 提交于 2019-12-18 12:05:54
问题 I am using attr to create a selector drawable for my project so that once i change theme colors, i dont have to make any change in the drawable file. I am using following libs: compile 'com.android.support:appcompat-v7:+' compile 'com.android.support:cardview-v7:+' compile 'com.android.support:design:22.2.0' Here is the source code for drawable: <?xml version="1.0" encoding="utf-8"?> <selector xmlns:android="http://schemas.android.com/apk/res/android"> <item android:drawable="?attr

Default selector background in Clickable Views

余生颓废 提交于 2019-12-18 10:05:00
问题 I have some clickable views and I want to set the default available background that is present on list click (in ICS is a blue color). I have tried putting as background this: android:background="@android:drawable/list_selector_background" but it is not the default blue I have by default (the one I used is orange). What is the drawable used by default on android as click selector? Thanks 回答1: It's list_selector_holo_dark or the equivalent holo light version; and these are the defaults in

saving gif file from drawable into phone sd? and remove it from sd after usage

£可爱£侵袭症+ 提交于 2019-12-18 09:43:23
问题 I have been searching on how to save file from Drawable into sd card OR phone's internal storage. All examples such as this one showed only for PNG type, I want to get GIF file from my drawable and save it into phone sd, and later remove it from sd after usage. Anybody please help with the code? I appreciate it! 回答1: As far as i know there isn't such a native function on Android (maybe related to patent issues). You may try this library for your purpose. Usually its meant to create animated

Rotating ImageView in Android < API Level 11

左心房为你撑大大i 提交于 2019-12-18 08:24:26
问题 So in API Level 11 Google introduced the ability to rotate an ImageView (Yay, after they introduced the possibility to Animate such a rotation, yay smart thinking, yay!) But how should I go about to rotate an ImageView using e.g. API level 8? I can't use setRotation() as described above. 回答1: RotationAnimation was present since Api level 1 RotateAnimation animation = new RotateAnimation(from, to, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f); animation.setInterpolator

Rotating ImageView in Android < API Level 11

梦想与她 提交于 2019-12-18 08:23:21
问题 So in API Level 11 Google introduced the ability to rotate an ImageView (Yay, after they introduced the possibility to Animate such a rotation, yay smart thinking, yay!) But how should I go about to rotate an ImageView using e.g. API level 8? I can't use setRotation() as described above. 回答1: RotationAnimation was present since Api level 1 RotateAnimation animation = new RotateAnimation(from, to, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f); animation.setInterpolator

resize image in android drawable

為{幸葍}努か 提交于 2019-12-18 07:19:17
问题 I have full resolution images in drawable folder need to resize according to phone screen size how to do that ? 回答1: Do it like this /************************ Calculations for Image Sizing *********************************/ public Drawable ResizeImage (int imageID) { //Get device dimensions Display display = getWindowManager().getDefaultDisplay(); double deviceWidth = display.getWidth(); BitmapDrawable bd=(BitmapDrawable) this.getResources().getDrawable(imageID); double imageHeight = bd

Can not pass bitmap between activities in android

别说谁变了你拦得住时间么 提交于 2019-12-18 07:00:44
问题 I need to change background of the activity dynamically , by selecting an image from an other activity. and passing the selected image back to the calling activity , but when i try to get the image , it is null. here is my code. public class SelectGoalBackground extends OrmLiteBaseActivity<DatabaseHelper> {// implements{ GridView gridview ; public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.select_goal_background); final String from =