?android:attr/selectableItemBackground not visible enough on a dark background

后端 未结 3 2030
挽巷
挽巷 2021-02-04 10:15

On Android Lollipop, I\'m using:

android:background=\"?android:attr/selectableItemBackground\"

to have the material animated feedback when I cl

相关标签:
3条回答
  • 2021-02-04 10:44

    There is another way to change the app theme:

    Theme.AppCompat.NoActionBar
    

    It works fine for me.

    0 讨论(0)
  • 2021-02-04 10:47

    Solution with AppCompat (works on old APIs too)

    android:theme="@style/Base.ThemeOverlay.AppCompat.Dark"
    android:background="?attr/selectableItemBackground"
    
    0 讨论(0)
  • 2021-02-04 10:53

    On API 21+ you can set android:theme="@android:style/ThemeOverlay.Material.Dark" on a View or ViewGroup to change all of the theme attributes (text color, ripple color, button color, etc.) to the "dark" versions. If you set it on a ViewGroup, the theme is also applied to all of the child elements during inflation. It's an easy way to have regions of "dark" in an otherwise "light" interface (or vice versa).

    <LinearLayout
        android:id="@id/my_dark_layout"
        ...
        android:theme="@android:style/ThemeOverlay.Material.Dark">
    
        <TextView
            android:id="@id/my_dark_bounded_ripple"
            ...
            android:background="?android:attr/selectableItemBackground"
            android:text="Bounded ripple" />
    
        <ImageButton
            android:id="@id/my_dark_unbounded_ripple"
            ...
            android:background="?android:attr/selectableItemBackgroundBorderless"
            android:src="@drawable/my_icon" />
    
    </LinearLayout>
    
    0 讨论(0)
提交回复
热议问题