首页 > 移动平台 > 详细

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

时间:2016-07-29 16:39:48      阅读:250      评论: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
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!