LinearLayout通过shape设置圆角,但是最下面的textView却没有圆角
2017-07-14 17:01
351 查看
1、效果图
2、问题描述
背景:上图是一个vertical的linearlayout,最底部是一个textView(我设置了linearlayout的高度正好包含这些视图,不能再高),我希望的效果是整个视图都有圆角,而上图却只有上方有圆角3、解决办法
单独给底部的textView设置一个shape作为背景,只设置底部有圆角(不要设置多个corners节点,否则只有第一个有效果)<?xml version="1.0" encoding="utf-8"?> <shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle" > <corners android:topLeftRadius="0dp" android:topRightRadius="0dp" android:bottomLeftRadius="3dp" android:bottomRightRadius="3dp" /> <solid android:color="@android:color/darker_gray"></solid> </shape>
然后,由于我这个textView的颜色是动态的,
GradientDrawable drawable = (GradientDrawable) textview.getBackground(); drawable.setColor(Color.parseColor(bean.buttonColor));
这段代码就可以修改颜色了
// GradientDrawable gd = new GradientDrawable();//创建drawable // gd.setColor(Color.parseColor(bean.buttonColor)); // float[] radious={0,0,3,3}; // gd.setCornerRadii(radious); // textview.setBackgroundDrawable(gd);
如果用这段代码,会引起白屏,具体原因一定要查一查,暂时我不明白为什么,希望路过的高手可以解答下
相关文章推荐
- shape为textView等设置圆角
- Android TextView中文字通过SpannableString来设置不同的属性:超链接、颜色、字体等属性
- 代码设置TextView、Button等控件圆角边框背景颜色
- Android中TextView通过SpannableString设置字体、大小、颜色、样式、超级链接
- android 通过html设置textview的内容不同种颜色
- 在我工作中,我想让RelativeLayout设置按钮的效果,但是有时候没有效果,下面的方法可以解决问题
- TextView Button 设置圆角背景
- Android给TextView设置透明背景、圆角边框
- 通过SpannableString为TextView设置丰富的显示效果
- Android TextView中文字通过SpannableString来设置超链接、颜色、字体等属性
- Android中TextView显示圆圈背景或设置圆角的方法
- Android TextView中文字通过SpannableString来设置超链接、颜色、字体等属性
- 通过Spannable对象设置textview的样式
- Android Shape Drawable Resources TextView渐变 背景色 圆角
- android 通过一Textview设置不同大小的字体颜色
- android TextView中文字通过SpannableString设置属性
- TextView实现跑马灯效果 以以实现TextView没有边框 设置我们自己的背景
- Android给TextView和EditText等控件设置透明背景、圆角边框
- 代码给textview设置倒圆角,简单暴力
- AndroidのTextView背景色、圆角、内部填充设置样式