边框显示在Android Studio中,但未在真实设备上显示
我有一个奇怪的问题。我使用以下代码作为布局的背景边框显示在Android Studio中,但未在真实设备上显示,android,xml,shapes,Android,Xml,Shapes,我有一个奇怪的问题。我使用以下代码作为布局的背景 <?xml version="1.0" encoding="utf-8"?> <layer-list xmlns:android="http://schemas.android.com/apk/res/android"> <item android:bottom="1dp" android:left="1dp" android:right="1dp"
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:bottom="1dp"
android:left="1dp"
android:right="1dp"
android:top="1dp">
<shape android:shape="rectangle">
<solid android:color="#ffffff" />
<corners android:radius="5dp" />
<stroke
android:width="2dp"
android:color="#23000000" />
</shape>
</item>
</layer-list>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/jobBox_container"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingBottom="10dp"
android:paddingLeft="10dp"
android:paddingRight="10dp"
android:background="@null">
<RelativeLayout
android:id="@+id/jobBox"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="@drawable/shadow_shape"
android:minHeight="100dp">
...
在Android Studio中,它看起来是这样的
但在真正的设备上,没有显示任何边界
起初我认为颜色可能太相似了,所以我用黑色作为边框颜色,但结果是一样的
这是我的布局
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:bottom="1dp"
android:left="1dp"
android:right="1dp"
android:top="1dp">
<shape android:shape="rectangle">
<solid android:color="#ffffff" />
<corners android:radius="5dp" />
<stroke
android:width="2dp"
android:color="#23000000" />
</shape>
</item>
</layer-list>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/jobBox_container"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingBottom="10dp"
android:paddingLeft="10dp"
android:paddingRight="10dp"
android:background="@null">
<RelativeLayout
android:id="@+id/jobBox"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="@drawable/shadow_shape"
android:minHeight="100dp">
...
有人能告诉我我做错了什么吗?这似乎是Android Studio的某种缺陷。虽然我更改了可绘制的XML,但我和旧的XML仍然没有从何处开始使用。我检查了一下我的抽屉里是否有重复的文件,但我发现了。无效缓存和重新启动也无法解决此问题
所以要解决这个问题,一个简单的重构>重命名就足够了。首先尝试增加边框的大小。我尝试了5dp和10dp,结果仍然是一样的@piyush,为了这样做,只需尝试25dp一次,就像你给父布局加上了填充10dp一样。同样尝试了,根据你的屏幕截图,结果仍然是一样的,我认为Android Studio是错误的,屏幕看起来不同,工具栏和内容之间没有空间,背景是白色而不是灰色,而且你使用的是20 API,选择与手机上相同的,还可以在开发者设置中调整手机上的边框,以查看元素的位置。。。试着把它改成手机版,而不是预览版