shapedrawable

chagnge color of shape drawable programatically

纵然是瞬间 提交于 2020-01-05 08:20:34
问题 i need to chage color of shape drawable programatically... i am using this <shape xmlns:android="http://schemas.android.com/apk/res/android" > <solid android:color="@color/app_theme_blue" /> <corners android:radius="8dp" /> <padding android:bottom="10dp" android:left="10dp" android:right="10dp" android:top="10dp" /> </shape> Here i required to change color of android:color="@color/app_theme_blue" . please help me. 回答1: Yes, you can. And it's really super easy. First of all, keep in mind that

Get a textView background color with ShapeDrawable

女生的网名这么多〃 提交于 2020-01-05 02:57:08
问题 I have a textview with the background defined in a xml file. <TextView android:id="@+id/event_tvColor" android:layout_width="40dip" android:layout_height="40dip" android:text=" " android:background="@drawable/et_style_color_service_edit" android:clickable="true" /> xml file : et_style_color_service_edit.xml <?xml version="1.0" encoding="UTF-8"?> <shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="oval"> <solid android:color="@color/eventColor"/> <stroke android

Android: RoundRectShape: Modify corner radii

。_饼干妹妹 提交于 2019-12-29 09:36:31
问题 I have a RoundRectShape that is drawn in a View 's onDraw() function. The corners of this shape are modified by any drag actions on this view through an overridden onTouchEvent function (which calls invalidate() to force the call to onDraw() ). When initialising variables in onDraw , Eclipse shows a warning saying Avoid object allocations during draw/layout operations (preallocate and reuse instead) . This issue is explained as follows: You should avoid allocating objects during a drawing or

Applying ColorFilter to ImageView with ShapedDrawable

人盡茶涼 提交于 2019-12-27 17:23:59
问题 I have an ImageView with android:src set to a ShapedDrawable , namely a white circle. What I want is to colorize this ImageView in runtime responding to some events. imgView.setColorFilter seems to be solution, but after using this (tried different parameters) the image becomes invisible (I don't see it at the screen). How to solve this? And are there better ways to have color circles? 回答1: Alright, I had a quick play with this and noticed your issue of the circles disappearing. Without you

Scaling then rotating a rectangle drawable

江枫思渺然 提交于 2019-12-24 09:51:03
问题 I would like to scale a rectangle drawable downwards, then rotate it so once it is clipped by the view it resembles a trapezoid with the left side slanted: The rotation is working fine: <?xml version="1.0" encoding="utf-8"?> <layer-list xmlns:android="http://schemas.android.com/apk/res/android" > <item > <rotate android:fromDegrees="-19.5" android:toDegrees="-19.5" android:pivotX="0%" android:pivotY="0%" > <shape android:shape="rectangle" > <solid android:color="@android:color/black" /> <

Animate Android Ring Shape's sweep angle

ぃ、小莉子 提交于 2019-12-22 04:09:16
问题 Attempting to animate the Android Ring Shape to produce an effect similiar to the shown sequence of images. I have found the Shape Drawable type of Ring. <shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="ring" android:innerRadius="75dp" android:thickness="25dp" android:useLevel="false"> Along with the ArcShape(startAngle, sweepAngle) method. ShapeDrawable shape = new ShapeDrawable(new ArcShape(0, 360)); shape.setIntrinsicHeight(100); shape.setIntrinsicWidth(100)

How to make bottom border in drawable shape XML selector?

 ̄綄美尐妖づ 提交于 2019-12-19 05:34:13
问题 I'm trying to create a drawable shape with different states for my button. So I wrote this: <selector xmlns:android="http://schemas.android.com/apk/res/android" > <item android:state_pressed="true" android:color="@android:color/black" > <shape android:shape="rectangle" > <solid android:color="@color/NEGATIVE_pressed" /> <stroke android:width="1dp" android:color="@color/ORANGE" /> <corners android:radius="4dp" /> </shape> </item> <item android:state_focused="true" android:color="@android:color

Android dashed line drawable potential ICS bug

谁都会走 提交于 2019-12-18 10:40:27
问题 The following is a dashed line, defined as a ShapeDrawable in XML: <shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="line"> <size android:height="2dp" android:width="700dp" /> <stroke android:width="1dp" android:color="@android:color/black" android:dashWidth="1dp" android:dashGap="2dp" /> </shape> This will draw a nice dotted line on several Gingerbread phones. On the Galaxy Nexus however, the dashes appear to be ignored and the shape is drawn as a contiguous

Gradient Radius as percentage of screen size

回眸只為那壹抹淺笑 提交于 2019-12-17 18:01:15
问题 I'm trying to create a shape drawable with radial gradient background, with radius that will adjust to the screen size (take a look at the relevant documentation). This is my code: <?xml version="1.0" encoding="utf-8"?> <shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle" > <gradient android:endColor="#000" android:gradientRadius="50%p" android:startColor="#5d2456" android:type="radial" /> </shape> But it doens't seem to work. if I remove the "%p", it

android adding dots line to layout

余生长醉 提交于 2019-12-14 02:39:05
问题 i need to add a line of dots to my layout like this this is my layout <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="wrap_content" android:layout_height="wrap_content" android:background="@drawable/deals_list_item_bckg" android:orientation="horizontal" > <ImageView android:id="@+id/dealImg" android:layout_width="100dp" android:layout_height="100dp" android:scaleType="fitXY" android:src="@drawable/deals_list