android studio上的黑色按钮操作
我在android studio上将按钮颜色更改为黑色,如下所示: 在colors.xml中:android studio上的黑色按钮操作,android,xml,android-button,android-theme,material-components-android,Android,Xml,Android Button,Android Theme,Material Components Android,我在android studio上将按钮颜色更改为黑色,如下所示: 在colors.xml中: <color name="colorBlack">#000000</color> #000000 在styles.xml中: <style name="AppTheme.Button" parent="Base.Widget.AppCompat.Button"> <item na
<color name="colorBlack">#000000</color>
#000000
在styles.xml中:
<style name="AppTheme.Button" parent="Base.Widget.AppCompat.Button">
<item name="colorButtonNormal">@color/colorBlack</item>
</style>
@彩色/彩色黑色
在layou_frag.xml中:
<Button
android:id="@+id/button"
android:theme="@style/AppTheme.Button"
android:layout_width="match_parent"
android:layout_height="75dp"
android:text="@string/hello_first_fragment"
android:textColor="@color/design_default_color_background" />
我的黑色按钮工作正常,尽管按下按钮时的色调背景色动作不再工作,因为按钮是超暗的,色调通常为深灰色。
![按钮2浅灰色onClick][1]
我想知道单击按钮时在何处可以更改着色操作?您可以使用以下内容覆盖
颜色控制高亮显示
属性:
<androidx.appcompat.widget.AppCompatButton
android:theme="@style/ThemeOverylay.Button"/>
使用如下选择器:
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:alpha="..." android:color="?attr/colorOnPrimary" android:state_pressed="true"/>
<item android:alpha="..." android:color="?attr/colorOnPrimary" android:state_focused="true" android:state_hovered="true"/>
<item android:alpha="..." android:color="?attr/colorOnPrimary" android:state_focused="true"/>
<item android:alpha="..." android:color="?attr/colorOnPrimary" android:state_hovered="true"/>
<item android:alpha="..." android:color="?attr/colorOnPrimary"/>
</selector>
您可以使用以下内容覆盖
colorControlHighlight
属性:
<androidx.appcompat.widget.AppCompatButton
android:theme="@style/ThemeOverylay.Button"/>
使用如下选择器:
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:alpha="..." android:color="?attr/colorOnPrimary" android:state_pressed="true"/>
<item android:alpha="..." android:color="?attr/colorOnPrimary" android:state_focused="true" android:state_hovered="true"/>
<item android:alpha="..." android:color="?attr/colorOnPrimary" android:state_focused="true"/>
<item android:alpha="..." android:color="?attr/colorOnPrimary" android:state_hovered="true"/>
<item android:alpha="..." android:color="?attr/colorOnPrimary"/>
</selector>