1.顶部标题导航栏
第一种
<RadioGroup
android:layout_width="match_parent"
android:layout_height="@dimen/dp_x100"
android:orientation="horizontal"
android:gravity="center"
android:background="@color/colorLightGray">
<RadioButton
android:id="@+id/tvCompetitionNo"
style="@style/listTabTxt1"
android:text="抢单任务"
android:checked="true"/>
<RadioButton
android:id="@+id/tvCompetitionYes"
style="@style/listTabTxt1"
android:text="抢单列表"/>
</RadioGroup>
<style name="listTabTxt1">
<item name="android:layout_width">@dimen/dp_x200</item>
<item name="android:layout_height">@dimen/dp_x80</item>
<item name="android:textSize">15sp</item>
<item name="android:gravity">center</item>
<item name="android:clickable">true</item>
<item name="android:button">@null</item>
<item name="android:textColor">@drawable/selector_nav_txt</item>
<item name="android:background">@drawable/selector_nav_background</item>
</style>
selector_nav_txt的样式
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_checked="true" android:color="@color/colorWhite"></item>
<item android:state_pressed="true" android:color="@color/colorWhite"></item>
<item android:state_focused="true" android:color="@color/colorWhite"></item>
<item android:color="@color/colorGreen"/>
</selector>
selector_nav_background的样式
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_checked="true" android:drawable="@drawable/shape_green_green"></item>
<item android:state_pressed="true" android:drawable="@drawable/shape_green_green"></item>
<item android:drawable="@drawable/border_green_green_square" ></item>
</selector>
shape_green_green
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<corners android:radius="@dimen/dp_x5"/>
<stroke android:width="@dimen/dp_x2" android:color="@color/colorGreen"/>
<solid android:color="@color/colorGreen"/>
</shape>
border_green_green_square
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<corners android:radius="@dimen/dp_x5"/>
<stroke android:width="@dimen/dp_x2" android:color="@color/colorGreen"/>
<solid android:color="@color/colorWhite"/>
</shape>
点击RadioButton,RadioButton.isChecked()
第二种
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:orientation="vertical"
android:gravity="center">
<TextView
android:id="@+id/tvTaskManageJie"
style="@style/listTabTxt"
android:text="已接单" />
<View style="@style/ViewLine0"
android:id="@+id/lineTaskManageJie"/>
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:orientation="vertical"
android:gravity="center">
<TextView
android:id="@+id/tvTaskManagePei"
style="@style/listTabTxt"
android:text="配送中"/>
<View style="@style/ViewLine0"
android:id="@+id/lineTaskManagePei" />
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:orientation="vertical"
android:gravity="center">
<TextView
android:id="@+id/tvTaskManageSigned"
style="@style/listTabTxt"
android:text="已签收"/>
<View style="@style/ViewLine0"
android:id="@+id/lineTaskManageSigned" />
</LinearLayout>
public void onPageSelected(int arg0) {
switch (arg0) {
case 0:
mTvTaskManageJie.setTextAppearance(getContext(), R.style.listTabTxtSelected);
mTvTaskManagePei.setTextAppearance(getContext(),R.style.listTabTxt);
mTvTaskManageSigned.setTextAppearance(getContext(),R.style.listTabTxt);
mLineTaskManageJie.setBackgroundColor( Color.parseColor("#1ABC9C") );
mLineTaskManagePei.setBackgroundColor( Color.parseColor("#EAEAEA") );
mLineTaskManageSigned.setBackgroundColor( Color.parseColor("#EAEAEA") );
break;
case 1:
mTvTaskManageJie.setTextAppearance(getContext(),R.style.listTabTxt);
mTvTaskManagePei.setTextAppearance(getActivity(),R.style.listTabTxtSelected);
mTvTaskManageSigned.setTextAppearance(getContext(),R.style.listTabTxt);
mLineTaskManageJie.setBackgroundColor( Color.parseColor("#EAEAEA") );
mLineTaskManagePei.setBackgroundColor( Color.parseColor("#1ABC9C") );
mLineTaskManageSigned.setBackgroundColor( Color.parseColor("#EAEAEA") );
break;
case 2:
mTvTaskManageJie.setTextAppearance(getContext(),R.style.listTabTxt);
mTvTaskManagePei.setTextAppearance(getContext(),R.style.listTabTxt);
mTvTaskManageSigned.setTextAppearance(getActivity(),R.style.
listTabTxtSelected);
mLineTaskManageJie.setBackgroundColor( Color.parseColor("#EAEAEA") );
mLineTaskManagePei.setBackgroundColor( Color.parseColor("#EAEAEA") );
mLineTaskManageSigned.setBackgroundColor( Color.parseColor("#1ABC9C") );
break;
}
}
2.登录中动画效果
<LinearLayout
android:id="@+id/btnLogin"
style="@style/LoginButton"
android:orientation="horizontal"
android:gravity="center">
<TextView
android:id="@+id/tvLogin"
style="@style/TextView0"
android:text="登录"
android:textColor="@color/white"/>
<ImageView
android:id="@+id/imgLoginLoading"
style="@style/ImageView2"
android:contentDescription="@null"
android:scaleType="centerInside"
android:visibility="gone"
android:src="@drawable/icon_loading"/>
</LinearLayout>
mIvLoginLoading.setVisibility( View.VISIBLE );
Animation operatingAnim = AnimationUtils.loadAnimation(LoginActivity.this, R.anim.loading);
mIvLoginLoading.startAnimation(operatingAnim);
mTvLogin.setText( "登录中" );
mBtnLogin.setClickable( false );
R.anim.loading
<set xmlns:android="http://schemas.android.com/apk/res/android">
<rotate
android:fromDegrees="0"
android:toDegrees="359"
android:duration="3000"
android:repeatCount="-1"
android:pivotX="50%"
android:pivotY="50%" />
</set>
3.TextView加border边框
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<solid android:color="#FFFFFF" />
<stroke
android:width="1dp"
android:color="#000000" />
<!--通过设置padding给四条边加边框,如果四边都有可以不设置padding-->
<padding
android:bottom="1dp"
android:top="1dp" />
</shape>