Issue
I've made a custom .xml file with the following code:
<?xml version="1.0" encoding="utf-8" ?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_pressed="false">
<layer-list>
<item>
<shape>
<stroke android:width="5dp" android:color="@color/colorAccent"/>
<corners android:radius="0dp"/>
</shape>
</item>
</layer-list>
</item>
<item android:state_pressed="true">
<layer-list>
<item>
<shape>
<stroke android:width="5dp" android:color="@color/colorAccent"/>
<corners android:radius="0dp"/>
</shape>
</item>
</layer-list>
</item>
</selector>
And in my activity_main.xml I have the following button:
<Button
android:background="@drawable/buttonname"
android:textColor="@color/colorAccent"
android:text="Next"
android:layout_marginVertical="30dp"
android:layout_gravity="center"
android:layout_width="200dp"
android:layout_height="50dp"/>
If I hover over @drawable/buttonname I see my intended design, but instead of the design, my button background is my colorPrimary from my styles folder, both in preview at Visual Studio as well as when it is emulated. I have already restarted Visual Studio several times, without avail. Am I forgetting something? Is there some solution to this problem?
Any help is appreciated.
Solution
The background works if I change the Button to a TextView and has the desired layout after I put the android:gravity="center" tag in.
Answered By - Unseptium
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.