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. [CF622F]The Sum of the k-th Powers

    题目大意:给你$n,k(n\leqslant10^9,k\leqslant10^6)$,求:$$\sum\limits_{i=1}^ni^k\pmod{10^9+7}$$ 题解:可以猜测是一个$k+1 ...

  2. BZOJ1257:[CQOI2007]余数之和——题解+证明

    http://www.lydsy.com/JudgeOnline/problem.php?id=1257 Description 给出正整数n和k,计算j(n, k)=k mod 1 + k mod ...

  3. mongo日常操作备忘

    修改 普通修改 插入数据: db.students.insert({ "name":"swrd", "age":32, "grad ...

  4. STL之四:list用法详解

    转载于:http://blog.csdn.net/longshengguoji/article/details/8520891 list容器介绍 相对于vector容器的连续线性空间,list是一个双 ...

  5. Codeforces Round #508 (Div. 2) E. Maximum Matching(欧拉路径)

     E. Maximum Matching 题目链接:https://codeforces.com/contest/1038/problem/E 题意: 给出n个项链,每条项链左边和右边都有一种颜色(范 ...

  6. Android HandlerThread分析

    基础概念:HandlerThread 是一个包含 Looper 的 Thread,我们可以直接使用这个 Looper 创建 Handler,本质上还是Thread Handler 必须要和 Loope ...

  7. POJ3186 DP

    Treats for the Cows Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 5753   Accepted: 29 ...

  8. liunx系统下安装mysql数据库5.7.13版本

    一:在/usr/local目录下解压安装包

  9. Spring 学习笔记之整合Hibernate

    Spring和Hibernate处于不同的层次,Spring关心的是业务逻辑之间的组合关系,Spring提供了对他们的强大的管理能力, 而Hibernate完成了OR的映射,使开发人员不用再去关心SQ ...

  10. [洛谷P3527] [POI2011]MET-Meteors

    洛谷题目链接:[POI2011]MET-Meteors 题意翻译 Byteotian Interstellar Union有N个成员国.现在它发现了一颗新的星球,这颗星球的轨道被分为M份(第M份和第1 ...