hedzr / android-file-chooser

a lightweight file/folder chooser or picker
Apache License 2.0
284 stars 62 forks source link

Button Background #78

Closed DatL4g closed 5 years ago

DatL4g commented 5 years ago

I have to change the button background. Buttons on my AndroidTV need an accent background to see where you are.

Guiorgy commented 5 years ago

Sorry, it seems I have been overriding button background drawable programmatically. use:

dependencies {
    implementation 'com.github.hedzr:android-file-chooser:1.2.0-SNAPSHOT'
}

and style:

<style name="buttonStyle" parent="FileChooserButtonStyle">
    <item name="android:textColor">...</item>
    <item name="android:background">...</item>
</style>

Beware though, if you set the background to be a static color, the button won't be highlighted when the user focuses on it. If you don't want to loose that, create a selector drawable:

<selector xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" tools:ignore="ResourceName">
    <item android:drawable="@color/selected" android:state_focused="true"/>
    <item android:drawable="@color/not_selected" android:state_focused="false"/>
    <item android:drawable="@color/not_selected"/>
</selector>

where not_selected is the color it will normally be and selected when the user focuses on that button with the dpad. then just <item name="android:background">@drawable/my_selector</item>

PS. alternatively, you can change the fileListItemFocusedDrawable attribute. By default, the buttons use the same background as the list items for consistency.

DatL4g commented 5 years ago

@Guiorgy @hedzr Does this SNAPSHOT support the MediaStore for Android Q?

hedzr commented 5 years ago

Not yet. I'm not sure that picking a file in Q or higher is necessary. If so, that should be a legacy app.