<!--
消息上面一行代码是:将一行分成多个等份,占其中1份
消息下面一行代码是:文本居中
最后两行代码,第一个是引用/drawable/xiaoxi.xml中的效果,点击前和点击后
后一行是引用/drawable/text_color.xml背景颜色
-->
<RadioButton
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="消息"
android:gravity="center"
android:button="@null"
android:drawableTop="@drawable/xiaoxi"
android:textColor="@drawable/text_color"
/>
res/drawbl文件夹中文件内容drawable/xiaoxi------------------------<?xml version="1.0" encoding="utf-8"?><selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_checked="false" android:drawable="@mipmap/weixin_normal">
<item android:state_checkable="true" android:drawable="@mipmap/weixin_pressed">
</selector>=========================================================================================text_color.xml----------------------<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_checked="false" android:color="@color/black">
<item android:state_checked="true" android:color="@color/green">
</selector>================================================================================================全局背景颜色文件res/values/colors.xml------------------------<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="colorPrimary">#3F51B5</color>
<color name="colorPrimaryDark">#303F9F</color>
<color name="colorAccent">#FF4081</color>
<color name="black">#000000</color>
<color name="white">#FFFFFF</color>
<color name="green">#00FF00</color>
</resources>==================================================文件:values/actity_xiaoxi.xml界面左右排列android:orientation="horizontal"<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".xiaoxi">
<RadioGroup
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginEnd="8dp"
android:layout_marginLeft="8dp"
android:layout_marginRight="8dp"
android:layout_marginStart="8dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="1.0"
android:orientation="horizontal"
app:layout_constraintStart_toStartOf="parent" >
<!--
消息上面一行代码是:将一行分成多个等份,占其中1份
消息下面一行代码是:文本居中
最后两行代码,第一个是引用/drawable/xiaoxi.xml中的效果,点击前和点击后
后一行是引用/drawable/text_color.xml背景颜色
-->
<RadioButton
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:button="@null"
android:drawableTop="@drawable/xiaoxi"
android:gravity="center"
android:text="消息"
android:textColor="@drawable/text_color" />
<RadioButton
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:button="@null"
android:drawableTop="@drawable/lianxiren"
android:gravity="center"
android:text="联系人"
android:textColor="@drawable/text_color" />
<RadioButton
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:button="@null"
android:drawableTop="@drawable/dongtai"
android:gravity="center"
android:text="动态"
android:textColor="@drawable/text_color" />
</RadioGroup>
</android.support.constraint.ConstraintLayout>
Powered by ddoss.cn 12.0
©2015 - 2025 ddoss
渝公网安备50011302222260号
渝ICP备2024035333号
【实验平台安全承诺书】
小绿叶技术社区,优化网络中,点击查看配置信息
主机监控系统: 安全防火墙已开启检查cc攻击-下载文件完成后等待10s 恢复访问,检查连接数低于峰值恢复访问
您的IP:216.73.216.110,2025-12-01 15:20:44,Processed in 0.01096 second(s).