相关疑难解决方法(0)

在v21前点击复选框

所以,我想将色调应用于AppCompat Checkbox.

棒棒糖一切正常:

android:buttonTint="@color/purple_FF4081"
Run Code Online (Sandbox Code Playgroud)

或者这样:

android:theme="@style/Theme.MyTheme.PurpleAccent"
Run Code Online (Sandbox Code Playgroud)

但设置任何这些参数并不会改变前Lollipop上的任何内容.仅在我colorAccent为应用主题设置时才有效.但我不希望所有小部件都改变它们的外观,只需要一个复选框.如果没有设置彩色抽屉,有没有办法做到这一点?

checkbox android

23
推荐指数
3
解决办法
2万
查看次数

Android 图像视图色调

在 xml 中为 ImageView 设置色调时,我收到一条警告,显示:-

必须使用 app:tint 而不是 android:tint

我为什么要使用 app:tint?

android

14
推荐指数
3
解决办法
4110
查看次数

改变材料图标的颜色?

我从这里下载了一些材料图标:

https://material.io/icons/

我很困惑如何将这些图标的颜色更改为drawables.我有一个Button图标在drawableLeft属性中,然后一些ImageButton图标设置,如下所示:

<Button
    android:text="Hey"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:drawableLeft="@drawable/ic_arrow_upward_black_24dp"
    android:stateListAnimator="@null" />

<ImageButton
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    app:srcCompat="@drawable/ic_arrow_downward_black_24dp"
    android:background="@null" />
Run Code Online (Sandbox Code Playgroud)

如何更改每个图标的颜色?

此外,如果我下载的图标是黑色,我如何将图标的颜色更改为透明的颜色?

android android-layout android-studio

12
推荐指数
2
解决办法
9516
查看次数

pre v23设备上的Android TextView DrawableTint

我们有什么方法可以在Drawable使用中着色TextView吗?DrawableTint仅适用于API级别23及更高级别.

目前我正在使用a Vertical Linear Layout来达到我的要求.

<LinearLayout style="@style/ChoiceIllustratorIconTextContainerStyle">

  <ImageView
    style="@style/ChoiceIllustratorImageStyle"
    android:contentDescription="@string/cd_university"
    android:src="@drawable/ic_account_balance_white_24dp" />

  <TextView
    style="@style/ChoiceIllustratorTextStyle"
    android:text="@string/ci_text_university" />

</LinearLayout>
Run Code Online (Sandbox Code Playgroud)

它看起来像,在此输入图像描述

Android工作室建议我使用Compound DrawbleTextView来实现这一目标.而且我能够实现它,但我找不到Tint可绘制的方法.

<TextView
   style="@style/ChoiceIllustratorTextStyle"
   android:drawablePadding="4dp"
   android:drawableTop="@drawable/ic_account_balance_white_24dp"
   android:text="@string/ci_text_university" />
Run Code Online (Sandbox Code Playgroud)

android textview xml-drawable

9
推荐指数
4
解决办法
7715
查看次数

使用ColorStateList色调值使ImageView/ImageButton膨胀时出错

使用ImageView/ ImageButton(AppCompatImageView/ AppCompatImageButton),其与一个风格属性的结合android:tint,这使得使用的ColorStateList资源工作在> = API 21细,但将引发InflateException对API <21.

首先,我甚至不知道AppCompatImageView / (Button)着色是否支持ColourStateListxml资源作为android:tint值,我似乎无法找到明确的答案.我可以在S/O上找到的建议建议实现TintableImageView等,但是这些答案已经过时了,而且从appcompat实现的来源看来,这应该是一个功能.

澄清这绝对是个问题.删除android:tint属性或将其设置为单个颜色资源有效.

另外要澄清一下,我知道这是可以通过编程实现的.我试图让它在xml中向后兼容.

最小的例子

activity_foo.xml

<android.support.v7.widget.AppCompatImageButton
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:src="@drawable/ic_caret_up"
                style="@style/IconButton.Primary"

/>
Run Code Online (Sandbox Code Playgroud)

styles.xml

<style name="IconButton.Primary">
    <item name="android:tint">@color/link_button_color</item>
</style>
Run Code Online (Sandbox Code Playgroud)

link_button_color.xml

<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">

  <item android:color="@color/btnLinkPressedTextColor"
      android:state_selected="true" />
  <item android:color="@color/btnLinkPressedTextColor"
      android:state_pressed="true" />
  <item android:color="@color/btnLinkTextColor" />

</selector>
Run Code Online (Sandbox Code Playgroud)

android tint android-appcompat imageview android-4.4-kitkat

5
推荐指数
1
解决办法
674
查看次数