2017-11-17 44 views
0

私はアンドロイドアプリで作業しています。背景と前景の両方のボタンが必要です。これはいくつかのアイコンです。ForegroundTintはボタン上のbackgroundTintを "上書き"しますか?

backgroundTintとforegroundTintを異なる色に設定したいのは、色のセレクタを書くときに必要になるからです。

問題は、私はforegroundTint設定した場合ということです!

  1. foregroundTintMode =乗算を - 背景の色合いはOKですが、フォアグラウンドアイコンは、それがカラー
  2. foregroundTintModeだ変更されていない=乗算 - フォアグラウンド色合いがOKですが、背景アイコンが色をforegroundTintに変更していますbackgroundTint

foregroundTintModeとbackgroundTintModeのすべての組み合わせを試しましたが、結果はありませんでした。

<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:app="http://schemas.android.com/apk/res-auto" 
    xmlns:tools="http://schemas.android.com/tools" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    tools:context="euroicc.testfb.MainActivity" 
    android:background="@color/colorPrimary"> 

    <Button 
     android:id="@+id/button" 
     android:layout_width="200dp" 
     android:layout_height="200dp" 
     android:background="@drawable/icon_background" 
     android:backgroundTint="@android:color/holo_blue_dark" 
     android:foreground="@drawable/icon_settings" 
     android:foregroundTint="@android:color/white" 
     tools:layout_editor_absoluteX="105dp" 
     tools:layout_editor_absoluteY="141dp" /> 

</RelativeLayout> 

注:

はここに私のテストファイルである私は、最初は17 LVL APIでの作業が、このアプリは、できるだけ多くのデバイスをサポートするために、私は希望の21に変更されました。

答えて

1

あなたは、通常のButtonと​​を使用している理由はわからない、代わりにImageButton使用:

<ImageButton 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:src="@drawable/icon_settings" 
    android:tint="@android:color/red" 
    android:background="@drawable/icon_background" 
    android:backgroundTint="@android:color/black" 
    /> 
+0

おかげで、これはトリックはなかったです。 –

関連する問題