【Android_樣式】Button 文字樣式變動

 <Button
                android:id="@+id/btn_showcamera_usephoto"
                android:layout_width="fill_parent"
                android:layout_height="fill_parent"
                android:layout_weight="1"
                android:background="@color/activity_showcameraview_bottom"
                android:gravity="center"
                android:text="@string/IDS_COMPAN_PAN_00036"
                android:textColor="@color/selector_showcamera_view_bottom"
                android:textSize="15dp"
                android:visibility="visible" />

selector_showcamera_view_bottom  以下:android

要在res文件夾下新建color文件夾,而後將selector_showcamera_view_bottom.xml放入裏面spa

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

    <item android:state_pressed="true" android:color="#a5d3f4"/>
 <!-- pressed -->
    <item android:state_focused="true" android:color="#a5d3f4"/>
 <!-- focused -->
    <item android:color="#ffffff"/>
 <!-- default -->

</selector>

activity_showcameraview_bottom 以下:code

<color name="activity_showcameraview_bottom">#222222</color>


=================================
xml

在代碼中設置:utf-8

button.setTextColor(getResources().getColorStateList(R.color.selector_showcamera_view_bottom))get

button.setTextColor(getResources().getColor(R.color.activity_showcameraview_bottom))
string

相關文章
相關標籤/搜索