删除/添加动态阴影效果

编程入门 行业动态 更新时间:2024-10-22 21:21:11
本文介绍了删除/添加动态阴影效果的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

在我的按钮禁用我需要删除的文字阴影效果,当按钮使我需要重新添加这种效果。

selector_btn.xml

<选择的xmlns:机器人=htt​​p://schemas.android/apk/res/android><项目    机器人:可绘制=@绘制/ btn_disabled    机器人:state_enabled =FALSE/><项目    机器人:可绘制=@绘制/ btn_ pressed    机器人:STATE_ pressed =真/><项目    机器人:可绘制=@绘制/ btn_default/>

styles.xml

<样式名称=TextShadow>    <项目名称=机器人:文字颜色>#FFFFFFFF< /项目>    <项目名称=安卓则shadowColor>#0D67B9< /项目>    <项目名称=机器人:shadowRadius> 2.0< /项目>    <项目名称=机器人:shadowDy>&-2.0 LT; /项目>< /风格><样式名称=BigButton父=TextShadow>    <项目名称=机器人:背景> @绘制/ selector_btn< /项目>< /风格>

解决方案

你必须做2不同模式样式启用和禁用状态并将其应用于TextView的时候禁用或反之亦然.. 。            <样式名称=TextShadow_disable>              <项目名称=机器人:文字颜色>#FFFFFFFF< /项目>               <项目名称=安卓则shadowColor>#0D67B9< /项目>              <项目名称=机器人:shadowRadius> 0℃; /项目>             <项目名称=机器人:shadowDy> 0℃; /项目>              < /风格>             <样式名称=TextShadow_enable>              <项目名称=机器人:文字颜色>#FFFFFFFF< /项目>             <项目名称=安卓则shadowColor>#0D67B9< /项目>             <项目名称=机器人:shadowRadius> 2.0< /项目>             <项目名称=机器人:shadowDy>&-2.0 LT; /项目>            < /风格>          文字样式=(的TextView)findViewById(R.id.mytext);          textstyle.setOnClickListener(新OnClickListener(){                @覆盖                公共无效的onClick(视图v){                    getTextStyle();                }            });

写下此方法来检查启用禁用;

公共无效getTextStyle(){           如果(textstyle.isEnabled()){                 textstyle.setTextAppearance(这一点,R.style.TextShadow_enable);                }             其他{                   textstyle.setTextAppearance(这一点,R.style.TextShadow_disable);                }          }

When my button disabled i need remove text shadow effect and when button enable I need add this effect again.

selector_btn.xml

<selector xmlns:android="schemas.android/apk/res/android"> <item android:drawable="@drawable/btn_disabled" android:state_enabled="false" /> <item android:drawable="@drawable/btn_pressed" android:state_pressed="true" /> <item android:drawable="@drawable/btn_default" />

styles.xml

<style name="TextShadow"> <item name="android:textColor">#ffffffff</item> <item name="android:shadowColor">#0D67B9</item> <item name="android:shadowRadius">2.0</item> <item name="android:shadowDy">-2.0</item> </style> <style name="BigButton" parent="TextShadow"> <item name="android:background">@drawable/selector_btn</item> </style>

解决方案

You have make 2 defferent styles for enable and disable condition and apply it to textview when it disable or vise versa ... <style name="TextShadow_disable"> <item name="android:textColor">#ffffffff</item> <item name="android:shadowColor">#0D67B9</item> <item name="android:shadowRadius">0</item> <item name="android:shadowDy">0</item> </style> <style name="TextShadow_enable"> <item name="android:textColor">#ffffffff</item> <item name="android:shadowColor">#0D67B9</item> <item name="android:shadowRadius">2.0</item> <item name="android:shadowDy">-2.0</item> </style> textstyle = (TextView) findViewById(R.id.mytext); textstyle.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { getTextStyle(); } });

write down this method to check enable disable;

public void getTextStyle() { if(textstyle.isEnabled()){ textstyle.setTextAppearance(this, R.style.TextShadow_enable); } else{ textstyle.setTextAppearance(this, R.style.TextShadow_disable); } }

更多推荐

删除/添加动态阴影效果

本文发布于:2023-11-12 03:50:37,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1580431.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:阴影   效果   动态

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!