Java 布局上的圆角
我希望我的Java 布局上的圆角,java,android,layout,rounded-corners,grid-layout,Java,Android,Layout,Rounded Corners,Grid Layout,我希望我的GridLayout具有圆角,就像下图中的3个按钮一样。对于视图的圆角,如按钮,文本视图等,是否需要不同的代码 gameplayGL.setBackgroundResource(R.drawable.roundedcorners); gameplayGL.setBackgroundColor(Color.BLUE); gameplayGL.getBackground().setAlpha(35); roundedcorners.xml <shape xmlns:andr
GridLayout
具有圆角,就像下图中的3个按钮一样。对于视图的圆角,如按钮
,文本视图
等,是否需要不同的代码
gameplayGL.setBackgroundResource(R.drawable.roundedcorners);
gameplayGL.setBackgroundColor(Color.BLUE);
gameplayGL.getBackground().setAlpha(35);
roundedcorners.xml
<shape
xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<corners
android:bottomLeftRadius="8dp"
android:bottomRightRadius="8dp"
android:topLeftRadius="8dp"
android:topRightRadius="8dp" />
</shape>
我确信调用setBackgroundColor(Color.BLUE)会覆盖setBackgroundResource()调用
尝试制作一个不同的可绘制资源,就是这样
<shape
xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<corners
android:bottomLeftRadius="8dp"
android:bottomRightRadius="8dp"
android:topLeftRadius="8dp"
android:topRightRadius="8dp" />
<solid
android:color="#350000FF" />
</shape>
然后将gridview的背景设置为该值。您可能需要使用color值才能获得所需的内容。我很确定调用setBackgroundColor(color.BLUE)会覆盖setBackgroundResource()调用
尝试制作一个不同的可绘制资源,就是这样
<shape
xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<corners
android:bottomLeftRadius="8dp"
android:bottomRightRadius="8dp"
android:topLeftRadius="8dp"
android:topRightRadius="8dp" />
<solid
android:color="#350000FF" />
</shape>
然后将gridview的背景设置为该值。您可能需要使用颜色值才能获得您想要的颜色。我是否尝试过我发布的代码?是的,它给出了我发布的图像的输出。请注意,3个按钮周围的布局没有圆角。我是否尝试过我发布的代码?是的,它给出了我发布的图像的输出。请注意,3个按钮周围的布局没有圆角。Dur!我早该知道的!这非常有效,谢谢!杜尔!我早该知道的!这非常有效,谢谢!