问题标签 [compound-drawables]

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 投票
0 回答
64 浏览

android - ListView 中单个视图的背景颜色

我正在构建一个 android GUI,目前我正在构建一个 ListView。我将 GUI 的其余外观基于各个视图的背景色。我尝试对 ListView 中的布局做同样的事情,但命令什么也不做。我通过测试和一些研究得出结论,是 ListView 强制透明。

这可以覆盖吗?请帮忙 :)

0 投票
2 回答
5676 浏览

android - 在事件上显示复合可绘制到 EditText

在我的 Activity 应用程序中,我想在EditText单击内部(焦点)EditText 并键入一个键清除时进行设置,该清除button 应出现在右侧EditText
当 EditText 为空时,必须删除该清除按钮。
但它没有向我展示..
我应该在这里实施哪个事件..?onTouchonFocusChangeaddTextChangedListener还有什么代码在那里..?以下代码我在活动中完成...

在活动中:

和事件作为


另一个事件是:


0 投票
1 回答
594 浏览

android - 使用不同的可绘制对象在 setCompoundDrawables 上获取不同的事件

我有一个EditText设置drawablesEditText. 我正在drawables用不同的场景切换它们。我有clearTextrefreshIcon作为我的drawables。这两个都在正确更改,但我无法为我的两个drawables. 这是我为清除文本所做的工作EditText

当我单击clearText drawable它时,它会清除文本。这很好很容易。

现在,我有另一个drawableie refreshIcon,当 onEditText refreshIcon出现时,它没有为刷新目的获取特定事件。

clearText我使用了与for相同的代码refreshIcon。我无法打印Logwhen refreshIconis clicked/touched

我在做什么?任何形式的帮助将不胜感激。

0 投票
1 回答
698 浏览

android - 在 EditText 背景外绘制复合可绘制对象

我正在尝试创建一个EditText带有自定义背景的,并且compound drawable在左侧,但在背景之外(目前它似乎与背景重叠);像这样的东西。-

在此处输入图像描述

这可能吗?

0 投票
1 回答
1540 浏览

android - 从 URL 加载 Compound Drawable 中的图像

我有一个listviewwith CompoundDrawable,复合中的图像drawable需要从网络加载。如何CompoundDrawable从 URL 加载图像。我认为我可以从 URL 中获取位图图像,将其转换为 Drawable,然后将其加载到 CompoundDrawable 中。像这样

有更好的方法吗?我可以直接做到这一点而不从 URL 获取位图然后将位图转换为可绘制的吗?

0 投票
0 回答
81 浏览

android - How to make a custom and compound objectin android?

After a lot search I found a great article that describes how to make compound objects. The recipe works great, Eclipse shows it in the custom made widgets. Fantastic.

http://mobile.cs.fsu.edu/creating-a-simple-compound-component-in-android/

Just one problem, I need a few of them. When I added a few into a layout, the resource id for the enclosing layer/object bumps as expected; that is, the new object receives new ids auomagically. The issue is the components inside the main layout do not; so if I need to use finViewById to get the view for internal components, they all have the same id. Does anyone know how to automagically assign different id for the internal components of the complex widget? I would try to assign them manually, but Eclipse does not show the internal structure of a compound object; so no help there.

-- in response to Xaver answer

Yes, at least I think I did. If I follow the example in the link I have something alike; now I see what you are saying, I got the views as just by adding findviewbyId to custom class, as this

What I cannot understand and I most likely have wrong is how to hook my code to two objects, that is following the example in the link

How does HorizontalNumberPicker construtor know is linked to object horizontal_number_picker or horizontal_number_picker2?

if in in my activity I add

what links to horizontal_number_picker or horizontal_number_picker2?

By the way how do I pass the Attributeset?

0 投票
2 回答
343 浏览

android - 索尼 Xperia S (LT26i) 似乎没有显示复合绘图

我们正在测试我们的新应用程序,我们为多个文本视图使用复合可绘制对象。不幸的是,索尼 Xperia S (LT26i) 忽略了 setCompoundDrawables 和 setCompoundDrawablesWithIntrinsicBounds。

任何人都可以确认这个错误吗?或者有人有解决方法吗?这种效果会影响其他手机吗?

谢谢和问候

0 投票
1 回答
109 浏览

android - 如何在xml中制作这种类型的drawable

我想在屏幕中心制作一个透明的圆圈,而在屏幕的其余部分制作一个不透明的圆圈。这可以用drawable吗?或者可以以编程方式完成。

我在地图上添加了一张图片。地图完美运行。但问题是我想支持多种分辨率,所以我不想使用不同的图像。 https://www.dropbox.com/sh/yyafqik996p4avp/AABc8ZMKi4pks_BQutQrbg8aa?dl=0

编辑:

1)地图图像是我的预期输出。2)Mapfilter 图像是我想使用可绘制或以编程方式创建的。3)输出图像是我在使用以下方法时得到的。

我用这个方法画了第二张图 http://pastebin.com/MUrH8gmS

我使用 setImageBitmap 方法将输出位图设置为我的图像视图

但现在的问题是它在图像的左右两侧留下了一些空间(参见 Output.png 图像)。如何删除它?

0 投票
1 回答
8640 浏览

android - How to vertically align text in a TextView with Compound Drawable

This question is in a way a continuation of my last question.

My problem now is pretty much the same, except that instead of separating the image and text in differend views (namely ImageView and TextView) I learned I can use the attribute android:drawableLeft to set an image "for" my text (the suggestion was pointed to me by Eclipse with a warning icon on the LinearLayout line).

I thought the only difference would be that instead of setting the ImageView with setImageResource() method I would simply set the TextView's drawableLeft attributed with the setCompoundDrawablesWithIntrinsicBounds() method. Instead, when I made the change, I was taken back to my original issue: the text aligns with the top edge of the view rather than the center.

This is what my TextView looks like:

The second View is just a separator.

... and this is what the layout looks like after setting the above mentioned attributes: (I don't have enough reputation to post images yet, so here's the link to it)

(Just to be clear, this is only a static example. My text and image are both set dynamically in the code at runtime).

Any help is greatly appreciated.

0 投票
1 回答
1083 浏览

android - 可绘制形状上的 setCompoundDrawables 无效

我正在尝试使用 Compound Drawables 为 TextView 设置上划线。我在 XML 可绘制资源中创建了一个线条形状,如下所示:

现在我试图把它作为我的 TextView 的上划线,如下所示:

但它完全忽略了指令并且没有出现上划线。我也考虑过使用 CompoundDrawablesWithIntrinsicBounds,但这也不起作用。形状的 XML 是错误的还是我以错误的方式使用该方法?非常感谢您!

编辑:我尝试使用 XML android:drawableTop 属性,但仍然没有运气。在这一点上,我认为形状本身显然存在问题。完整代码在这里:

我的 java 与 Android Studio 中给出的“Hello World”默认示例完全相同: