码迷,mamicode.com
首页 > 移动开发 > 详细

Android:pressed状态下,改变背景和Text样式

时间:2016-07-29 16:41:58      阅读:262      评论:0      收藏:0      [点我收藏+]

标签:

技术分享

需求:准确控制Text的高度,pressed时候,同时改变背景和text的样式。

用Button的话,不能准确控制text的高度。

用Image+TextView叠加的话,pressed时候,onClick事件会被两者中一个consume,因此text的样式,背景只能改变其中之一,代码中设置也很不方便。

目前比较好的实现:

Layout+TextView。监听layout即可。

<android.support.percent.PercentRelativeLayout
android:id="@+id/layout_cancel"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_centerVertical="true"
android:background="@drawable/bg_goto_setting_white"
app:layout_heightPercent="60%"
app:layout_marginLeftPercent="6.5%"
app:layout_widthPercent="42%">

<cc.makeblock.customview.FitHeightTextView
android:id="@+id/tv_cancel"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_centerVertical="true"
android:gravity="center"
android:text="稍后再说"
android:textColor="@color/color_text_black"
app:layout_heightPercent="60%"
/>
</android.support.percent.PercentRelativeLayout>

 

Android:pressed状态下,改变背景和Text样式

标签:

原文地址:http://www.cnblogs.com/makebetter/p/5718843.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!