Reputation: 45
I just started learning android and faced this issue. Watched a couple of tutorials but couldn't find the solution. So basically I want to add a button inside a grid layout. And I want Button color to be white. So I added android:background="#ffffff" in button attributes. But its still showing the default color, i.e., blue. Please help in changing the Button Color!!
Here is the xml code.
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#007b7e"
app:layout_behavior="@string/appbar_scrolling_view_behavior">
<androidx.gridlayout.widget.GridLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="30sp"
android:layout_row="3"
android:layout_column="3">
<Button
android:id="@+id/button10"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#ffffff"
android:textSize="18sp"
android:layout_margin="5sp"
android:gravity="fill"
android:text="Button"
app:layout_columnWeight="1"
app:layout_rowWeight="1"/>
</androidx.gridlayout.widget.GridLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
Upvotes: 0
Views: 68
Reputation: 190
Try use AppCompactButton instead of
<Button/>
use
<androidx.appcompat.widget.AppCompatButton />
that will do the trick
Upvotes: 3