Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/345.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 布局上的圆角_Java_Android_Layout_Rounded Corners_Grid Layout - Fatal编程技术网

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!我早该知道的!这非常有效,谢谢!杜尔!我早该知道的!这非常有效,谢谢!