Reputation: 3912
I want my GridLayout
to have rounded corners like the 3 Buttons
do in the below picture. Does this require code that is different for rounding corners of Views such as Buttons
, TextViews
, etc?
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>
Upvotes: 2
Views: 1071
Reputation: 394
I'm pretty sure calling setBackgroundColor(Color.BLUE) overrides the setBackgroundResource() call.
Try making a different drawable resource that is this
<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>
Then setting the background of the gridview to that. You may have to play with the color value to get exactly what you want.
Upvotes: 4