android - Why is my drawable button layout not being applied to the button as a background?
问题描述
I have created a buttonbg.xml file to give a button a round shape with a custom color. Here's how the xml code looks like,
<stroke
android:color="#69B9F9"
android:width="3dp" />
<corners
android:radius="200dp" />
But when i apply this xml as a background to the button,
<Button android:id="@+id/loginButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentStart="true"
android:layout_alignParentEnd="true"
android:layout_alignParentBottom="true"
android:layout_marginStart="59dp"
android:layout_marginEnd="61dp"
android:layout_marginBottom="227dp"
android:background="@drawable/button_bg"
android:text="LOGIN"
android:textSize="22sp" />
Nothing happens,
Please help me out!
解决方案
Add this to your button
app:backgroundTint="@null"
Also in your question you've written
I have created a buttonbg.xml file
and in your code you've written button_bg.xml. Please check if the typo exist in your code or just in the question itself
推荐阅读
- solr - 如何在 Solr 中查询包含正斜杠的字符串
- c# - 从我的数据库(MySQL)中获取值并自动操作游戏对象
- directx - Direct3D11:“在具有不同迭代的循环中使用梯度指令,强制循环展开”,警告:X3570
- javascript - 在 ul 和 li 标签中添加和删除类时面临问题
- sql - 在 SQL Server 中存储图像
- reactjs - NWJS 应用程序路由在开发中运行良好,构建版本不路由
- firebase - 如何从firebase实时数据库中的另一个数据库条目中引用一些信息以及来自c的一些信息
- python - 如何更新 PyInstaller 生成的 exe 详细信息?
- php - Docker 在具有 curl 支持的 alpine 映像上构建 php 失败。我该如何解决?
- javascript - 如何通过单击按钮在页面上创建多个表