drawable

Share image with Android intent

人走茶凉 提交于 2019-12-10 10:25:54
问题 I'm trying to share an image trough a share intent like this: Intent sharingIntent = new Intent(android.content.Intent.ACTION_SEND); sharingIntent.setType("image/png"); sharingIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, application.getString(R.string.app_name)); sharingIntent.putExtra(android.content.Intent.EXTRA_TEXT,application.getString(R.string.app_share_message)); File image = new File(Uri.parse("android.resource://" + C.PROJECT_PATH + "/drawable/" + R.drawable.icon_to_share)

How android drawable automatically change?

浪子不回头ぞ 提交于 2019-12-10 10:15:30
问题 I have a android application, that uses many images. and application is to be used on different resolutions. I am using only one set of images and images are saved in "drawable-mdpi". So "The images gets blur when I run it on a high resolution". So probably the solution of this is to save different images of different resolution in drawable-hdpi,ldpi etc. Is doing this is enough or do I have to change the images by code? or phone automatically adjust the perfact image into the drawables. can

Change Button Drawable Programmatically [duplicate]

喜欢而已 提交于 2019-12-10 10:07:44
问题 This question already has answers here : How to programmatically set drawableLeft on Android button? (13 answers) Closed 2 years ago . I have a button with drawable left: <Button android:id="@+id/post_feeling_btn" android:background="@color/white" android:layout_width="match_parent" android:layout_height="wrap_content" android:padding="4dp" android:drawableLeft="@drawable/feeling_btn" android:gravity="left|center_vertical" android:textColor="@color/gray" android:text="Sentimento"/> In my on

Scale drawableLeft in button with text

半腔热情 提交于 2019-12-10 04:35:29
问题 I have a button with text and a drawable on the left. Is there any way I can make that drawable scale to it's appropriate size (fill button's height) while keeping its aspect ratio? Relevant excerpt from my layout: <Button android:text="@string/add_fav" android:id="@+id/event_fav_button" android:layout_width="match_parent" android:layout_height="40dp" android:drawableLeft="@drawable/star_yellow"/> 回答1: You can resize an image on basis of the dimension of a Button, use getHeight() and getWidth

Programmatically create ShapeDrawable

China☆狼群 提交于 2019-12-10 01:23:18
问题 I'm trying to programmatically create a ShapeDrawable but the following code doesn't show anything. ImageView image = new ImageView (context); image.setLayoutParams (new LayoutParams (200, 200)); ShapeDrawable badge = new ShapeDrawable (new OvalShape()); badge.setBounds (0, 0, 200, 200); badge.getPaint().setColor(Color.RED); ImageView image = new ImageView (context); image.setImageDrawable (badge); addView (image); I can get it working with xml. <?xml version="1.0" encoding="utf-8"?> <shape

How to rotate a drawable by ObjectAnimator?

こ雲淡風輕ζ 提交于 2019-12-09 14:11:10
问题 Alphaing a drawable work well like this: if(mAlphaAnimation == null){ mAlphaAnimation = ObjectAnimator.ofFloat(this, "alpha", 0.0f,1.0f).setDuration(TARGET_ANIM_ALPHA_DURATION); mAlphaAnimation.setInterpolator(new AccelerateDecelerateInterpolator()); mAlphaAnimation.setStartDelay(TARGET_ANIM_ALPHA_DELAY_BASE*power); mAlphaAnimation.setRepeatCount(ValueAnimator.INFINITE); mAlphaAnimation.setRepeatMode(ValueAnimator.REVERSE); mAlphaAnimation.addUpdateListener(this); } But if I want rotate a

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

Creating a shortcut: how can I work with a drawable as Icon?

天大地大妈咪最大 提交于 2019-12-09 04:50:26
问题 Below is My code to create a shortcut to a selected application. I have really no problem and the application work quite well. The problem is that I am able to create a shortcut with a ressource from my application: intent.putExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE, Intent.ShortcutIconResource.fromContext(this, R.drawable.icon)); But I really would like with a custom drawable. ( Drawable myDrawable=.....) How can I do? ResolveInfo launchable=adapter.getItem(position); final Intent

Android Gradient drawable programmatically

℡╲_俬逩灬. 提交于 2019-12-09 02:36:55
问题 I have a gradient drawable defined in xml that I use it as a background, like this: <?xml version="1.0" encoding="utf-8"?> <layer-list xmlns:android="http://schemas.android.com/apk/res/android"> <item android:bottom="4dp"> <shape> <gradient android:startColor="@color/blue" android:endColor="@color/dark_blue" android:angle="270" /> </shape> </item> <item android:top="98dp"> <shape> <gradient android:startColor="@color/black" android:endColor="@color/transparent_black" android:angle="270" /> <

Animating TextView's leftDrawable using ObjectAnimator

和自甴很熟 提交于 2019-12-09 01:15:06
问题 I would like to animate leftDrawable of a TextView , I tried the following: ObjectAnimator.ofFloat(drawable, "rotation", 0f, 360f).setDuration(300).start(); button.setCompoundDrawablesWithIntrinsicBounds(drawable, null, null, null); But it doesn't seem to animate, in the past I've used AnimationDrawable and it works by putting several drawables in a <animation-list> , but apk size is a concern so I'm trying to avoid having multiple assets to achieve this. Please let me know if I've done