我正在使用API级别14. setBackgroundDrawable已弃用且setBackground抱怨为API级别16.那么我可以使用什么来设置我的背景可绘制?
是否可以使用Layer-List实现以下作为drawable(用于背景)?

谢谢!
我正在尝试创建一个将在onTouchEvent上调整大小的圆形。
我关注了可调整大小的矩形帖子,但我认为由于缺乏数学知识,我不知道如何创建可调整大小的圆圈。
我试过改变
canvas.drawRect(
left + colorballs.get(0).getWidthOfBall() / 2,
top + colorballs.get(0).getWidthOfBall() / 2,
right + colorballs.get(2).getWidthOfBall() / 2,
bottom + colorballs.get(2).getWidthOfBall() / 2, paint);
Run Code Online (Sandbox Code Playgroud)
到canvas.drawCircle() ; 它创建了圆圈,但不是我想要的。
你能告诉我是否已经实现了这样的东西,或者我应该遵循哪些点来将这个矩形示例转换为可调整大小的圆。
令人困惑的是,“背景”也经常被用来简单地表示“用于 Android 的照片的‘背景颜色’:src”。
说我有。
<ImageView
android:src="@drawable/white_foreground_thing"
android:background="@drawable/some_bg_thing"
/>
Run Code Online (Sandbox Code Playgroud)
我要更改setColorFilter。
事实上,这是否仅影响“src” - 即前景。
或者它也会影响背景。?
android:background="@drawable/some_bg_thing"
Run Code Online (Sandbox Code Playgroud)
在我的示例中,前景(即 src)是一个 40 像素的白点(因此,我将制作“不同颜色的点”)。
但是背景只是一个普通的按钮背景,实际上还带有一些透明度等等。
所以我不想影响背景;我将只更改不同按钮的“大点的颜色”。
请注意,(a) 从测试中很难确定,setColorFilter 的微妙之处和 (b) 我真的在 doco 中找不到它(对你来说,Android 伙计们可能很明显!)
进一步 - PosterDuff.Mode 在这里相关吗?或者这完全无关紧要?
顺便说一下,在许多情况下,这里是一个很棒的解决方案。/sf/answers/1242964411/
(注意底部的彩色圆点)
但在这里,我只想找出地狱 setColorFilter 影响 .background 还是只影响 .src
我知道所有其他措施,但我找不到在哪里可以看到最后一项措施,任何链接或信息将不胜感激...
我做的:
ShapeDrawable.ShaderFactory shaderFactory = new ShapeDrawable.ShaderFactory() {
@Override
public Shader resize(int width, int height) {
LinearGradient linearGradient = new LinearGradient(0, 0, width, height,
new int[]{
0xF44336,
0xFFB74D,
0xFFE082,
0xAED581,
0x4CAF50,
0xAED581,
0xFFE082,
0xFFB74D,
0xF44336},
new float[]{
0, 0.125f, 0.25f, 0.375f, 0.5f, 0.625f, 0.75f, 0.875f, 1.0f},
Shader.TileMode.REPEAT);
return linearGradient;
}
};
PaintDrawable paint = new PaintDrawable();
paint.setShape(new RectShape());
paint.setShaderFactory(shaderFactory);
Run Code Online (Sandbox Code Playgroud)
但是,当我在视图中将其设置为背景时,我什么都看不到。
有一次,当我在 Moto E 上升级到棒棒糖时,小通知图标变成了黑白(我读到它是新的谷歌指南)。所以好吧,我可以忍受它。现在我注意到图标又变了颜色,我没有改变我的代码并且一直在使用相同的可绘制对象。它肯定是黑白相间的,现在是彩色的。我的设备运行的是 Android 5.0.2 另外:
compileSdkVersion 22
buildToolsVersion "22.0.1"
targetSdkVersion 22
Run Code Online (Sandbox Code Playgroud)
这是我的代码:
NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(
this)
.setVibrate(new long[] { 10, 10, 10, 10, 10 })
.setSound(alarmSound)
.setSmallIcon(R.drawable.logo)
.setContentTitle(title)
.setStyle(new NotificationCompat.BigTextStyle().bigText(msg))
.setContentText(msg);
Run Code Online (Sandbox Code Playgroud)
谁能告诉我这是怎么发生的?
notifications android push-notification android-drawable android-5.0-lollipop
我想要自定义形状边框,如下所示:
这是我迄今为止尝试过的:
<?xml version="1.0" encoding="UTF-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<solid android:color="#00000000"/>
<stroke android:width="0.1dp" android:color="#FFFFFF" />
<corners android:radius="5dp"/>
<!--<padding android:left="5dp" android:top="5dp" android:right="5dp" android:bottom="5dp" />-->
</shape>
Run Code Online (Sandbox Code Playgroud)
但这并没有给我弯曲的侧面,只有弯曲的角落。
我需要弯曲的侧面
android xml-drawable android-canvas android-drawable android-shapedrawable
想知道如何在TextView.xml中调整xml中图像的大小LinearLayout。我阅读了一些使用setCompoundDrawablesWithIntrinsicBounds方法的解决方案,但无法正确解决。
这是图片:
我想减小徽标的大小。
这是我的TextView代码:
<TextView
android:id="@+id/heading"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:drawableLeft="@drawable/android_logo"
android:drawableStart="@drawable/android_logo"
android:gravity="top"
android:padding="16dp"
android:singleLine="true"
android:text="@string/heading"
android:textSize="20dp"
android:drawablePadding="5dp"/>
Run Code Online (Sandbox Code Playgroud) android ×10
android-drawable ×10
android-ui ×1
drawable ×1
shape ×1
textview ×1
xml-drawable ×1