Android drawableTint在使用过的AppCompact-v7:25.3.1中不起作用
这个问题在这里已经存在了。但我想一步一步地了解这一点。 我将依赖项粘贴在gradle的依赖项下Android drawableTint在使用过的AppCompact-v7:25.3.1中不起作用,android,xml,Android,Xml,这个问题在这里已经存在了。但我想一步一步地了解这一点。 我将依赖项粘贴在gradle的依赖项下 compile 'com.android.support:appcompat-v7:25.3.1' 而不是做什么。 我的xml代码在这里 <Button android:id="@+id/button_not_working" android:layout_width="match_parent" android:layout_height="wrap_content"
compile 'com.android.support:appcompat-v7:25.3.1'
而不是做什么。
我的xml代码在这里
<Button
android:id="@+id/button_not_working"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/imageViewGroup"
android:layout_marginTop="60dp"
android:paddingEnd="9dp"
android:layout_alignStart="@+id/imageViewGroup"
android:layout_alignEnd="@+id/imageViewGroup"
android:background="@drawable/button_background"
android:text="Drawable Tine not working"
android:textColor="@color/white"
android:textSize="@dimen/font_size_small"
android:textAlignment="center"
android:layout_marginBottom="10dp"
android:drawableEnd="@drawable/forword_arrow"
android:drawableTint="@color/white"
android:gravity="center"
/>
这是照片
前进箭头的颜色没有改变。
这里有几个答案,但我想知道一步一步地做什么。
就是这样。您必须使用
色调
编辑:我的错误,应该是backgroundTint
文本视图中的着色复合可绘制内容(及其子代,如按钮)是通过Android:drawableint
和Android:drawableintmode
属性引入API 23(Android 6)的
到今天为止,此功能尚未向后移植到AppCompat支持库
当然,我自己也试图解决这个问题。去图书馆看看。它有XpAppCompatTextView
和xpappcompattbutton
小部件。您的代码可能如下所示:
<android.support.v7.widget.XpAppCompatButton
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Drawable tint working"
android:drawablePadding="8dp"
app:drawableEnd="@drawable/forword_arrow"
app:drawableTint="?android:textColorPrimary"/>
要获取库,请将其放入您的应用程序模块build.gradle中:
repositories {
maven { url 'https://dl.bintray.com/consp1racy/maven/' }
}
dependencies {
compile 'net.xpece.android:appcompat-extra:1.2.0'
}
api可拉伸着色的可能重复是的,我看到了答案,但你能帮助我一步一步地理解吗?在没有.java文件的帮助下,我只能通过xml文件来处理这个问题吗?@DimaKozhevin这是关于在文本视图中着色复合绘图表的。这与图像可绘制的着色无关。@EugenPechanec我的错误。如果关闭此按钮,则有可能复制此按钮。我检查问题中的注释是否可以解决。两行代码:AppCompatButton b=findViewById(R.id.button\u不工作);Drawable[]drawables=b.getCompoundDrawables();Drawable wrappDrawable=DrawableCompat.wrap(drawables[2]);setTint(wrapDrawable,getResources().getColor(android.R.color.white))代码>tint
用于ImageView和ImageButton的前景图像<代码>背景色调
用于背景drawableTint
用于文本视图或按钮的复合可绘制项。另外,app:tint
和android:tint
之间也有区别(其他属性也是如此)<代码>应用程序:tint
自支持库25.4.0以来按预期工作。
repositories {
maven { url 'https://dl.bintray.com/consp1racy/maven/' }
}
dependencies {
compile 'net.xpece.android:appcompat-extra:1.2.0'
}