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. I/O复用----select

    2018-07-31 (星期二)I/O复用:    一个应用程序通常需要服务一个以上的文件描述符.    例如stdin,stdout,进程间通信以及若干文件进行I/O,如果不借助线程的话,(线程通常 ...

  2. [luogu1654]OSU!

    update 9.20:本篇题解已经被\(yyb\)证明是出锅的 这道题目最后的式子看上去是很简单的,不到10行就码完了,但是求式子的过程并没有那么简单. 很容易想到一种枚举思路: 因为每一段连续的1 ...

  3. Leetcode中字符串总结

    本文是个人对LeetCode中字符串类型题目的总结,纯属个人感悟,若有不妥的地方,欢迎指出. 一.有关数字 1.数转换 题Interger to roman和Roman to integer这两题是罗 ...

  4. [Leetcode] minimum window substring 最小字符窗口

    Given a string S and a string T, find the minimum window in S which will contain all the characters ...

  5. 项目管理---git----快速使用git笔记(六)------本地开发与远程仓库的交互----常用git命令

    无论是我们自己把本地的项目新建了一个远程仓库 还是 从远程仓库获取到了 本地,现在我们都在本地有了一份项目代码,服务器上对应有项目代码的信息. 现在我们就开始进行交互操作了. 也就是说明一些在 正常开 ...

  6. 删边(cip)

    删边(cip) 给出一个没有重边和自环的无向图,现在要求删除其中两条边,使得图仍然保持连通. 你的任务是计算有多少组不合法的选边方案.注意方案是无序二元组. Sol 神题,无从下手啊. 考虑点dfs建 ...

  7. mybaties实体的 Mapper.xml文件中自定义sql时模糊查询的写法

    <select  id=selectByNameLike" parameterType="string" resultMap="BaseResultMap ...

  8. HDU4625:Strongly connected(思维+强连通分量)

    Strongly connected Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Other ...

  9. 【IntelliJ IDEA 12使用】导入外部包

    以前用eclipse,现在用IntelliJ IDEA,发现它确实是个很不错的工具. 用IntelliJ IDEA12这个版本导入外部JAR包,这样来操作,打开Project Structure,在m ...

  10. [ASP.NET]从ASP.NET Postback机制,到POST/GET方法

    写这篇博客的起源来自于自己最近在学习ASP.NET时对于 PostBack机制的困惑.因为自己在解决困惑地同时,会不断产生新的疑问,因此博客最后深入到了http 包的格式和Internet所使用的TC ...