点击TextView后,让TextView颜色变黑,并字下面的一蓝色下划线,在线等

zgycsmb 2011-11-18 11:45:11
android布局中的tab1xml中包含了另一xml,如下
<LinearLayout android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="40dip">
<include layout = "@layout/bottom" />
</LinearLayout>

其中被包含的bottom.xml:
<?xml version="1.0" encoding="gb2312"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<LinearLayout android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="40dip"
android:background="#434343"
>
<TextView
android:id="@+id/bottomtextView1"
android:layout_width="80dip"
android:layout_height="40dip"
android:text="首页"
android:layout_gravity="center"
android:gravity="center"
android:textColor="#FFFFFF"
android:textSize="14dip"
android:paddingTop="6dip"
/>
</LinearLayout>
</LinearLayout>

现需:点击 界面上的 首页 二字后,首页所在TextView这一块变成黑色,并首页 二字下面有一蓝色下划线,这如何实现呀,thanks
...全文
721 9 打赏 收藏 转发到动态 举报
写回复
用AI写文章
9 条回复
切换为时间正序
请发表友善的回复…
发表回复
lenomonxiao 2011-12-30
  • 打赏
  • 举报
回复
TextView实现某段文字的点击可以用ClickSpan,给某段文字添加背景可以使用BackgroundSpan

你可以看看这里Android使用TextView实现无下划线超链接
lingang1359 2011-11-23
  • 打赏
  • 举报
回复
我怎么感觉跟3.2 默认的TAB风格一样?LZ可以去参考一下3.2的API DEMOS里面的代码。
jacyGmail 2011-11-22
  • 打赏
  • 举报
回复
两转图片 一张无背景色 一张有背景色有下划线 然后写个selector 就可以了

布局也是可以实现的稍微麻烦点儿
BuleRiver 2011-11-19
  • 打赏
  • 举报
回复
使用图片吧,呵呵
ahaso 2011-11-18
  • 打赏
  • 举报
回复
TextView放在一个layout里,点击后layout背景变为黑色,textview下面放一个imageview,开始用setVisibility设为不可见,点击设为可见
路人丙 2011-11-18
  • 打赏
  • 举报
回复
bottom.xml 文件中 TextView下添加 ImageView蓝色下划线图片 默认为不显示 当点击“首页”时 TextView 所在LinearLayout背景变为 黑色 并且蓝色下划线图片显示。
哈哈 。。。
zgycsmb 2011-11-18
  • 打赏
  • 举报
回复
楼上的二位,能详细点吗,多谢,
jacyGmail 2011-11-18
  • 打赏
  • 举报
回复
用图片吧 简单
b87936260 2011-11-18
  • 打赏
  • 举报
回复
不要用textview,建议使用checkbox,去掉背景

80,350

社区成员

发帖
与我相关
我的任务
社区描述
移动平台 Android
androidandroid-studioandroidx 技术论坛(原bbs)
社区管理员
  • Android
  • yechaoa
  • 失落夏天
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧