app直播原始碼,為文字/圖片新增按壓效果

zhibo系統開發發表於2023-02-17

app直播原始碼,為文字/圖片新增按壓效果

1、文字

layout佈局:

<TextView
     android:layout_width="@dimen/textview_button_width" 
     android:layout_height="match_parent" 
     android:text="@string/wifi_item_hulv"
     android:textColor="@drawable/selector_upgrade_text_press"
     android:textSize="@dimen/text_size_selected" />


selector_upgrade_text_press xml檔案

<?xml version="1.0" encoding="utf-8"?> 
<selector xmlns:android="
   <item 
      android:color="@color/text_pressed_blue" android:state_pressed="true" />
   <item 
      android:color="@color/switch_general_track_check_color"/> 
</selector>


2、svg圖片

layout佈局:

<ImageView android:id="@+id/iv_bt_loading_down" 
android:layout_width="@dimen/wifi_signal_height" 
android:layout_height="@dimen/wifi_signal_height" 
android:background="@drawable/ic_icon_general_update_72" />


svg圖片:

<vector xmlns:android="
   android:width="72dp" 
   android:height="72dp" 
   android:viewportWidth="72" 
   android:viewportHeight="72"> 
 <path 
    android:pathData="M0.5,0.5h71v71h-71z" 
    android:strokeAlpha="0" 
    android:strokeWidth="1" 
    android:fillColor="#D8D8D8" 
    android:strokeColor="#979797" 
    android:fillType="evenOdd" 
    android:fillAlpha="0"/> 
 <path android:pathData="M21,34.5C21.8284,34.5 22.5,35.1716 22.5,36C22.5,
     43.4558 28.5442,49.5 36,49.5C39.6279,49.5 43.0248,48.0644 45.5407" 
    android:strokeWidth="1" 
    android:fillColor="@color/selector_upgrade_ic_press" 
    android:fillType="nonZero" 
    android:strokeColor="#00000000"/> 
</vector>


在res目錄下新建一個color目錄,然後在這個color目錄下新建一個selector_upgrade_ic_press xml檔案

<?xml version="1.0" encoding="utf-8"?>
<selector   
  xmlns:android="
  <item android:color="@color/ic_state_pressed" android:state_pressed="true" />
  <item android:color="@color/ic_state_not_pressed"/>
</selector>


3、文字按鈕

layout佈局:

<TextView
  android:id="@+id/btn_pincode_cancel"
  style="@style/ConfirmButtonNew" 
  android:paddingStart="@dimen/confirm_btn_padding_start"
  android:paddingTop="@dimen/confirm_btn_padding_top"
  android:background="@drawable/round_blue_bg"
  app:layout_constraintStart_toStartOf="parent"
  app:layout_constraintBottom_toBottomOf="parent"
  android:text="@string/cancel"/>
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="
  <item android:state_pressed="false">
    <shape>
      <corners android:radius="@dimen/round_bg_radius" />
      <solid android:color="@color/round_blue_bg_color"/>
    </shape>
  </item>
 <item android:state_pressed="true">
   <shape>
     <corners android:radius="@dimen/round_bg_radius" />
     <solid android:color="@color/round_blue_bg_color_press"/>
   </shape>
  </item>
</selector>


 以上就是 app直播原始碼,為文字/圖片新增按壓效果,更多內容歡迎關注之後的文章


來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/69978258/viewspace-2935745/,如需轉載,請註明出處,否則將追究法律責任。

相關文章