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. 求熵 python 代码

    #coding=gbk import nltk import math def entropy(labels): freqdist = nltk.FreqDist(labels) #Frequency ...

  2. 配置和修改springboot默认国际化文件

    SpringBoot默认国际化文件为:classpath:message.properties,如果放在其它文件夹中,则需要在application.properties配置属性spring.mess ...

  3. [Violet]蒲公英

    description 在线询问区间众数. data range \[n\le 40000,m\le 50000,a_i\le 10^9\] solution 自己分块不行于是\(\%\)了\(yyb ...

  4. [SCOI2007]组队 差分

    题面:[SCOI2007]组队 题解: 一开始固定H然后找性质找了很久也没有找到任何有用的东西...... 然后大佬告诉我一个神奇的方法... 首先我们化一波式子: 设$H$表示高度的最小值,$V$表 ...

  5. 51NOD 1353:树——题解

    http://www.51nod.com/onlineJudge/questionCode.html#!problemId=1353 今天小a在纸上研究树的形态,众所周知的,有芭蕉树,樟树,函树,平衡 ...

  6. HDOJ(HDU).1016 Prime Ring Problem (DFS)

    HDOJ(HDU).1016 Prime Ring Problem (DFS) [从零开始DFS(3)] 从零开始DFS HDOJ.1342 Lotto [从零开始DFS(0)] - DFS思想与框架 ...

  7. 从零开始学Linux系统(一)之引导流程解析

    Linux系统:分时多用户多任务的操作系统: Linux系统引导流程: inittab配置文件中: 定义了linux系统的运行的7个级别:从0~6 0.6:分别代表关机和重启,不建议设置为默认的运行级 ...

  8. [学习笔记]2-SAT 问题

    (本文语言不通,细节省略较多,不适合初学者学习) 解决一类简单的sat问题. 每个变量有0/1两种取值,m个限制条件都可以转化成形如:若x为0/1则y为0/1等等(x可以等于y) 具体: 每个变量拆成 ...

  9. ACE反应器(Reactor)模式(1)

    转载于:http://www.cnblogs.com/TianFang/archive/2006/12/13/591332.html 1.ACE反应器框架简介 反应器(Reactor):用于事件多路分 ...

  10. Base class does not contain a constructor that takes '0' argument

    刚刚在写一段直播室网站中的一段程序遇,突然遇到一个错误,如下 'TVLLKBLL.BaseClass' does not contain a constructor that takes 0 argu ...