问题标签 [shapedrawable]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票
10 回答
11104 浏览

android - 如何在 XML drawable 中创建一个具有两个弯曲边的矩形?

我希望矩形的左侧和右侧(而不是角)弯曲。或者说椭圆形的顶部和底部是直的。

我怎样才能实现这样的目标?

在此处输入图像描述

0 投票
4 回答
22843 浏览

android - ActionBar Compat 的自定义(渐变)背景

我正在使用 Action Bar Compat,以便我的带有导航抽屉的操作栏向后兼容到 API 级别 9,我想更改操作栏的背景。

我从Android Developers复制了代码:

问题来了。

当我将可绘制的图像或颜色作为背景时,它可以正常工作。但是我想将背景定义为渐变形状,所以我actionbar_background看起来像:

我希望它以水平方式重复,但即使这样也会导致错误,事实上,非常有趣的错误。当我尝试运行应用程序时,测试设备甚至模拟器都会重新启动。我能够DeadObjectException在重新启动之前捕捉到。

背景可绘制对象应该如何?

0 投票
1 回答
3028 浏览

android - android:shape="line" not visible

I have the following drawable shape:

And use this with this image:

When I set android:layout_height to 1dp, the shape is not visible. If the android:layout_height is set to 2dp, the shape is visible.

Why do I have to use a height of 2dp?

Ralph

0 投票
4 回答
3658 浏览

android - ShapeDrawable作为Android中RatingBar的progressDrawable?

看来我无法将 ShapeDrawable 设置为 Ratingbar 的 progressDrawable。我尝试了以下但失败了:

myRatingbar 风格:

ratingbar_full.xml:

屏幕上什么都没有显示。

编辑:使用 .png 而不是 shape 适用于这一行:

@drawable/ratingbar_full

0 投票
0 回答
568 浏览

android - Android形状可绘制是否可以凹角?

我为按钮的背景创建了一个可绘制的 Shape 并凸出角落:

但这让我开始思考是否可以“凹入”形状的角落?我尝试将其设置为减号:

但这不起作用,所以希望有人知道这是否可能?

我想要的“外观”类似于以下内容:

我想要的形状可绘制样本

0 投票
1 回答
598 浏览

android - Android shape drawable 中缺少圆角显示(仅在三星 Galaxy Tab 7.0 上)

我只是想显示一个带有圆角(半径 3dp)的描边矩形(描边宽度 1dp)。在大多数设备上一切看起来都很好,但在三星 Galaxy Tab 7.0 plus N 上,边角显示不正确。代码如下:

这是结果。它在 Kindle Fire HD 上看起来不错(例如),但在 Galaxy Tab 上不太好:

银河标签 7.0 Kindle Fire HD

Kindle 的屏幕分辨率更高,但在分辨率低于 Galaxy Tab 的设备上看起来也不错。您对如何规避这个问题有任何想法,还是我只需要忍受它?

0 投票
6 回答
22565 浏览

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

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 getting corner

Here is the code where I am passing Color.TRANSPARENT for 'fill' in the constructor:

}

0 投票
1 回答
1179 浏览

android - 检测是否在 shapeDrawable 内发生触摸事件

我正在自定义 android 视图中通过画布绘制许多 ShapeDrawables。我有一个 onTouchEvent 方法,它工作正常。一切正常。现在我希望能够检测触摸事件是否与某个 ShapeDrawable 相交(即发生在内部)。有没有办法做到这一点?

0 投票
2 回答
2581 浏览

android - android在布局中添加点线

我需要像这样在我的布局中添加一行点

在此处输入图像描述

这是我的布局

我可以通过哪种方式做这件事我也尝试使用ShapeDrawable但仍然不明白它是如何工作的我需要一个例子来看看它是如何工作的以及如何在描述文本视图和价格文本视图之间的布局中做到这一点

0 投票
7 回答
75471 浏览

android - Android如何以编程方式创建三角形和矩形?

我们如何创建气球可绘制形状,如下所示。我们可以动态改变它的颜色。 在此处输入图像描述