shapedrawable

How are you supposed to use a ShapeDrawable with a PathShape to draw a line on a custom View?

你说的曾经没有我的故事 提交于 2019-12-12 08:12:20
问题 I am attempting to draw a line in a custom View . Here I've created a simple Path with just a single segment, created a PathShape from that, and finally stuck that into a ShapeDrawable with the intention of using that to draw on the Canvas inside onDraw() . However, this does not work. See my example, here. package com.example.test; import android.content.Context; import android.graphics.Canvas; import android.graphics.Color; import android.graphics.Paint; import android.graphics.Path; import

What is wrong with my layer-list drawable?

女生的网名这么多〃 提交于 2019-12-10 22:16:25
问题 I wanted to set a custom drawable to be the android:src of FloatingActionButton in this layout: <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:sscce="http://schemas.android.com/apk/res-auto" android:orientation="vertical" android:layout_width="match_parent" android:layout_height="match_parent" > <android.support.design.widget.FloatingActionButton android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center" sscce

Can I override some attribute of drawable shape?

二次信任 提交于 2019-12-10 19:08:37
问题 I have two buttons, they are same shape, only color is different b1.xml <?xml version="1.0" encoding="utf-8"?> <shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle"> <corners android:radius="10dp" /> <stroke android:width="5px" android:color="#000000" /> <solid android:color="#ff0000"/> </shape> b2.xml <?xml version="1.0" encoding="utf-8"?> <shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle"> <corners android:radius

Call setImageDrawable from RemoteViews

醉酒当歌 提交于 2019-12-10 10:33:46
问题 I have done this in an Activity and it works perfectly. ImageView myImage = (ImageView) findViewById(R.id.myImageView); ShapeDrawable mDrawable; mDrawable = new ShapeDrawable(new OvalShape()); mDrawable.getPaint().setColor(0xff74AC23); mDrawable.setBounds(x, y, x + width, y + height); mDrawable.setIntrinsicWidth(width); mDrawable.setIntrinsicHeight(height); myImage.setImageDrawable(mDrawable); Now I want to do the same thing in a widget (inside onUpdate ) and I have to use RemoteViews to

ShapeDrawable(from a PathShape) not drawing on correct coordinates

喜你入骨 提交于 2019-12-08 05:11:34
问题 I'm trying to create a ShapeDrawable that draws the following path: Path path = new Path(); path.moveTo(50, 20); path.lineTo(0, 50); path.lineTo(50, 100); ShapeDrawable shapeDrawable = new ShapeDrawable(new PathShape(path, someNumber ,someNumber )); Then I put shapeDrawable as the top layer of a Layer drawable like so: Drawable layers[] = new Drawable[2]; layers[0] = res.getDrawable(R.drawable.crawford01); layers[1] = shapeDrawable; LayerDrawable layerDrawable = new LayerDrawable(layers);

How to programmatically create a round cornered border using ShapeDrawable in android?

依然范特西╮ 提交于 2019-12-06 17:25:43
问题 I need to create a border with rounded corners programatically by extending ShapeDrawable. I need to have a black border with rounded corners with the pixels on the outside being white and the inner pixels being transparent. The code I have at the moment has multiple problems, of which are that it does not create a smooth corner that is the same thickness as the border and that the outer pixels of the border are transparent and not white. Here is a picture of the corners I am currently

ShapeDrawable as progressDrawable for RatingBar in Android?

只愿长相守 提交于 2019-12-03 22:08:47
问题 It seems I cannot set ShapeDrawable as progressDrawable for Ratingbar. I tried the following but failed: <RatingBar android:id="@+id/ratingbar" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentBottom="true" android:numStars="5" android:stepSize="1.0" android:rating="3.0" style="@style/myRatingBar" /> myRatingbar style: <style name="myRatingBar" parent="@android:style/Widget.RatingBar"> <item name="android:progressDrawable">@drawable/ratingbar

How are you supposed to use a ShapeDrawable with a PathShape to draw a line on a custom View?

岁酱吖の 提交于 2019-12-03 16:09:09
I am attempting to draw a line in a custom View . Here I've created a simple Path with just a single segment, created a PathShape from that, and finally stuck that into a ShapeDrawable with the intention of using that to draw on the Canvas inside onDraw() . However, this does not work. See my example, here. package com.example.test; import android.content.Context; import android.graphics.Canvas; import android.graphics.Color; import android.graphics.Paint; import android.graphics.Path; import android.graphics.drawable.ShapeDrawable; import android.graphics.drawable.shapes.PathShape; import

Custom (gradient) background of ActionBar Compat

吃可爱长大的小学妹 提交于 2019-12-03 12:39:06
问题 I am using Action Bar Compat so that my action bar with navigation drawer was backward compatible down to API level 9 and I want to change the background of the action bar. I copied the code from Android Developers: <?xml version="1.0" encoding="utf-8"?> <resources> <!-- the theme applied to the application or activity --> <style name="CustomActionBarTheme" parent="@style/Theme.AppCompat.Light.DarkActionBar"> <item name="android:actionBarStyle">@style/MyActionBar</item> <!-- Support library

Custom (gradient) background of ActionBar Compat

半腔热情 提交于 2019-12-03 03:49:35
I am using Action Bar Compat so that my action bar with navigation drawer was backward compatible down to API level 9 and I want to change the background of the action bar. I copied the code from Android Developers : <?xml version="1.0" encoding="utf-8"?> <resources> <!-- the theme applied to the application or activity --> <style name="CustomActionBarTheme" parent="@style/Theme.AppCompat.Light.DarkActionBar"> <item name="android:actionBarStyle">@style/MyActionBar</item> <!-- Support library compatibility --> <item name="actionBarStyle">@style/MyActionBar</item> </style> <!-- ActionBar styles