AS 选项切换效果
来源:互联网 发布:域名注册可靠吗 编辑:程序博客网 时间:2024/06/16 11:18
1.效果图
2.说明
页面其实就是2个button,自定义了4个shape
其他实现的方式很多,我选取了此种
3.其中使用的shape
(1).shapleft.xml
<?xml version="1.0" encoding="UTF-8"?><shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle"> <gradient android:angle="90" android:endColor="@android:color/transparent" android:startColor="@android:color/transparent"/> <corners android:bottomLeftRadius="15dp" android:bottomRightRadius="0dp" android:topLeftRadius="15dp" android:topRightRadius="0dp"/> <stroke android:width="1dip" android:color="#ffffffff"/></shape>
(2).shapeleft_focus.xml
<?xml version="1.0" encoding="UTF-8"?><shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle"> <gradient android:angle="90" android:endColor="#ffdddddd" android:startColor="#ffdddddd"/> <corners android:bottomLeftRadius="15dp" android:bottomRightRadius="0dp" android:topLeftRadius="15dp" android:topRightRadius="0dp"/> <stroke android:width="1dip" android:color="#ffffffff"/></shape>
(3).shaperight.xml
<?xml version="1.0" encoding="UTF-8"?><shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle"> <gradient android:angle="90" android:endColor="@android:color/transparent" android:startColor="@android:color/transparent"/> <corners android:bottomLeftRadius="0dp" android:bottomRightRadius="15dp" android:topLeftRadius="0dp" android:topRightRadius="15dp"/> <stroke android:width="1dip" android:color="#ffffffff"/></shape>
(4).shaperight_focus.xml
<pre name="code" class="html"><?xml version="1.0" encoding="UTF-8"?><shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle"> <gradient android:angle="90" android:endColor="#ffdddddd" android:startColor="#ffdddddd"/> <corners android:bottomLeftRadius="0dp" android:bottomRightRadius="15dp" android:topLeftRadius="0dp" android:topRightRadius="15dp"/> <stroke android:width="1dip" android:color="#ffffffff"/></shape>
4.页面布局 xml
<pre name="code" class="html"><RelativeLayout android:layout_width="wrap_content" android:layout_height="wrap_content"> <Button android:id="@+id/btnBrand" android:layout_width="100dp" android:layout_height="35dp" android:background="@drawable/shapeleft_focus" android:text="品牌" android:textColor="#ffffffff" /> <Button android:id="@+id/btnCondition" android:layout_width="102dp" android:layout_height="35dp" android:layout_marginLeft="98dp" android:background="@drawable/shaperight" android:text="筛选" android:textColor="#ffffffff" /> </RelativeLayout>
5.后台代码实现
{Button btnBrand; Button btnCondition; @Override public View onCreate(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { btnBrand = (Button) view.findViewById(R.id.btnBrand); btnCondition = (Button) view.findViewById(R.id.btnCondition);btnBrand.setOnClickListener(new TabClick()); btnCondition.setOnClickListener(new TabClick()); } class TabClick implements View.OnClickListener{ @TargetApi(Build.VERSION_CODES.JELLY_BEAN) @Override public void onClick(View v) { switch (v.getId()){ case R.id.llBrand: btnBrand.setBackground(getResources().getDrawable(R.drawable.shapeleft_focus)); btnCondition.setBackground(getResources().getDrawable(R.drawable.shaperight)); break; case R.id.llCondition: btnBrand.setBackground(getResources().getDrawable(R.drawable.shapeleft)); btnCondition.setBackground(getResources().getDrawable(R.drawable.shaperight_focus)); break; } } }}
0 0
- AS 选项切换效果
- 选项卡切换效果
- 新闻切换选项卡效果
- 新闻切换选项卡效果
- 选项卡切换效果总结
- tab选项卡切换效果
- 切换选项卡tab效果
- JS实现选项卡切换效果
- Tab选项卡切换效果JavaScript汇总
- Fragment实现底部选项卡切换效果
- tab -选项卡切换js效果
- javascript实现选项卡切换效果
- 简单是选项卡切换效果~
- Table选项卡切换效果的实现
- 实现选项卡切换的效果
- js实现选项卡切换效果
- fragment实现选项卡切换效果
- 原生javascript实现选项卡切换效果
- Apple 企业开发者账号&邓白氏码申请记录
- 输出一个字符串的全排列
- java map的遍历
- linux内核模型---总线,设备,驱动在展讯平台上I2C设备的实例解析
- Open Settings.app When Button is Tapped in UIAlertView on iPhone SDK [duplicate]
- AS 选项切换效果
- 【leetcode】Compare Version Numbers
- 简易连连看
- 资源打包Assetbundle
- 一个纯C#的Lua 5.2实现
- Jsoup 问题
- [Leetcode]Linked List Cycle
- 第七周项目 1 实现复数类中的运算符重载(1)
- Linux系统下修改环境变量PATH路径的方法