xml

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
android:id="@+id/relOrder"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@color/White"
xmlns:android="http://schemas.android.com/apk/res/android"> <RadioGroup
android:id="@+id/rgTabTitle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:paddingBottom="@dimen/text_padding_small"
android:paddingTop="@dimen/text_padding_small" > <RadioButton
android:id="@+id/rbDoneOrder"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1.0"
android:checked="true"
android:button="@null"
android:gravity="center"
android:padding="0dp"
android:text="@string/order_done"
android:textColor="@drawable/sel_tab_text_color"
android:textSize="@dimen/content_text_size" />
<RadioButton
android:id="@+id/rbGoingOrder"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1.0"
android:button="@null"
android:gravity="center"
android:padding="0dp"
android:text="@string/order_going"
android:textColor="@drawable/sel_tab_text_color"
android:textSize="@dimen/content_text_size" />
</RadioGroup> <LinearLayout
android:id="@+id/indicatorLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/rgTabTitle"
android:orientation="horizontal"
android:weightSum="2" > <View
android:id="@+id/indicatorView"
android:layout_width="0dp"
android:layout_height="@dimen/indicator_height"
android:layout_weight="1.0"
android:background="@color/bg_deep_color" />
</LinearLayout> <View
android:id="@+id/line1"
android:layout_width="match_parent"
android:layout_height="@dimen/divider_line_width"
android:layout_below="@id/indicatorLayout"
android:background="@color/divider_line_color" /> <FrameLayout
android:id="@+id/frContractsHistory"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@id/line1"
android:layout_marginTop="0dp"
android:layout_marginRight="@dimen/outer_border_width"
android:layout_marginLeft="@dimen/outer_border_width"
android:background="@color/White" > </FrameLayout> </RelativeLayout>

code:

mIndicator = mRootView.findViewById(R.id.indicatorView);//underlne
WindowManager wm = (WindowManager) context //the the width of screen
.getSystemService(Context.WINDOW_SERVICE);
DisplayMetrics outMetrics = new DisplayMetrics();
wm.getDefaultDisplay().getMetrics(outMetrics);
mIndicatorStepDistance = outMetrics.widthPixels; mFm =getFragmentManager();
FragmentTransaction mFragmentTrans =mFm.beginTransaction();
mFragmentTrans.add(R.id.frContractsHistory, new OrderContractsLvFragment(R.layout.list_item_contract_done)).commit();
mRgTabs.setOnCheckedChangeListener(new OnCheckedChangeListener(){
@Override
public void onCheckedChanged(RadioGroup container, int checkedId) {
FragmentTransaction mFragmentTrans =mFm.beginTransaction();
TranslateAnimation anim = null;
switch(checkedId){
case R.id.rbDoneOrder:
Toast.makeText(mContext, "done", Toast.LENGTH_LONG).show();
mFragmentTrans.replace(R.id.frContractsHistory,
new OrderContractsLvFragment(R.layout.list_item_contract_done));
mFragmentTrans.commit();
anim = new TranslateAnimation(mIndicatorStepDistance * mIndicatorPosition, 0, 0, 0);
mIndicatorPosition = 0;
break;
case R.id.rbGoingOrder:
Toast.makeText(mContext, "going", Toast.LENGTH_LONG).show();
mFragmentTrans.replace(R.id.frContractsHistory,
new OrderContractsLvFragment(R.layout.list_item_contract_ongoing));
mFragmentTrans.commit(); anim = new TranslateAnimation(mIndicatorStepDistance * mIndicatorPosition, mIndicatorStepDistance, 0, 0);
mIndicatorPosition = 1;
break;
}
if (anim != null) {
anim.setDuration(300);
anim.setFillAfter(true);
mIndicator.startAnimation(anim);
}
}
});

RadioButton 带下划线切换的案例的更多相关文章

  1. TabTopUnderLineLayout【自定义顶部选项卡(带下划线)】

    版权声明:本文为HaiyuKing原创文章,转载请注明出处! 前言 自定义顶部选项卡布局LinearLayout类,实现带下划线样式的效果. 备注:如果配合Fragment的话,MainActivit ...

  2. TabTopAutoLayout【自定义顶部选项卡区域(带下划线)(动态选项卡数据且可滑动)】

    版权声明:本文为HaiyuKing原创文章,转载请注明出处! 前言 自定义顶部选项卡布局LinearLayout类,实现带下划线且可滑动效果.[实际情况中建议使用RecyclerView] 备注:如果 ...

  3. FragmentTabHostUnderLineDemo【FragmentTabHost带下划线】

    版权声明:本文为HaiyuKing原创文章,转载请注明出处! 前言 使用FragmentTabHost实现顶部选项卡(带下划线效果)展现. 效果图 代码分析 1.该Demo中采用的是FragmentT ...

  4. 关于python中带下划线的变量和函数 的意义

    总结: 变量: 1.  前带_的变量:  标明是一个私有变量, 只用于标明, 外部类还是可以访问到这个变量 2.  前带两个_ ,后带两个_ 的变量:  标明是内置变量, 3.  大写加下划线的变量: ...

  5. delphi 仅带下划线的TEdit控件

    在做录入框的时候,很希望有一个只带下划线的文本框,网上介绍的很多,有自己做组件的,须不知Delphi下只需要简单设置几个属性即可达到目的.

  6. geotools导入shp文件到Oracle数据库时表名带下划线的问题解决

    问题: 最近在做利用geotools导入shp文件到Oracle表中,发现一个问题Oracle表名带下划线时导入失败,问题代码行: dsOracle.getFeatureWriterAppend(or ...

  7. [转]关于python中带下划线的变量和函数的意义

    Python 的代码风格由 PEP 8 描述.这个文档描述了 Python 编程风格的方方面面.在遵守这个文档的条件下,不同程序员编写的 Python 代码可以保持最大程度的相似风格.这样就易于阅读, ...

  8. Python里的单下划线,双下划线,以及前后都带下划线的意义

    Python里的单下划线,双下划线,以及前后都带下划线的意义: 单下划线如:_name 意思是:不能通过from modules import * 导入,如需导入需要:from modules imp ...

  9. 【转】关于python中带下划线的变量和函数 的意义

    http://www.blogjava.net/lincode/archive/2011/02/02/343859.html 总结: 变量: 1.  前带_的变量:  标明是一个私有变量, 只用于标明 ...

随机推荐

  1. Android 自定义View消除锯齿实现图片旋转,添加边框及文字说明

    先看看图片的效果,左边是原图,右边是旋转之后的图:   之所以把这个写出来是因为在一个项目中需要用到这样的效果,我试过用FrameLayout布局如上的画面,然后旋转FrameLayout,随之而来也 ...

  2. POJ3907:Build Your Home——题解

    http://poj.org/problem?id=3907 题目大意:求多边形面积,结果四舍五入. ———————————————————— 多边形面积公式板子题. #include<cstd ...

  3. XXE漏洞攻击与防御整理

    一.漏洞原理 1.DTD 文档类型定义(DTD)可定义合法的XML文档构建模块.它使用一系列合法的元素来定义文档的结构.DTD 可被成行地声明于 XML 文档中,也可作为一个外部引用. 内部的 DOC ...

  4. ES6箭头函数总结

    1. 箭头函数基本形式 let func = (num) => num; let func = () => num; let sum = (num1,num2) => num1 + ...

  5. bzoj1042: [HAOI2008]硬币购物(DP+容斥)

    1600+人过的题排#32还不错嘿嘿 浴谷夏令营讲过的题,居然1A了 预处理出f[i]表示购买价值为i的东西的方案数 然后每次询问进行一次容斥,答案为总方案数-第一种硬币超限方案-第二种超限方案-第三 ...

  6. 创建JavaScript的哈希表Hashtable

    Hashtable是最常用的数据结构之一,但在JavaScript里没有各种数据结构对象.但是我们可以利用动态语言的一些特性来实现一些常用的数据结构和操作,这样可以使一些复杂的代码逻辑更清晰,也更符合 ...

  7. foo.prototype作为新对象的原型来使用

    最近在研究js,疑惑也比较多.主要是被原型这个东西给弄迷糊了.疑惑出自于: function foo { this.name = 'foo'; } alert(foo.prototype === Fu ...

  8. IntelliJ IDEA 详细图解最常用的配置 ,适合新人,解决eclipse转idea的烦恼

    刚刚使用IntelliJ IDEA 编辑器的时候,会有很多设置,会方便以后的开发,磨刀不误砍柴工. 比如:设置文件字体大小,代码自动完成提示,版本管理,本地代码历史,自动导入包,修改注释,修改tab的 ...

  9. bzoj 4724 [POI2017]Podzielno 二分+模拟

    [POI2017]Podzielno Time Limit: 10 Sec  Memory Limit: 128 MBSubmit: 364  Solved: 160[Submit][Status][ ...

  10. 【java】AES加密解密|及Base64的使用

    转载自:http://www.cnblogs.com/arix04/archive/2009/10/15/1511839.html AES加解密算法,使用Base64做转码以及辅助加密: packag ...