[英]Android material design - Rounded corner view not correctly showing rounded shadow
I am trying to upgrade my app to incorporate material design. 我正在尝试升级我的应用程序以合并材料设计。 I have messed around a little with the elevation and translation elements, and have run into a problem.
我用高程和翻译元素搞砸了一些,并遇到了问题。 Namely, my rounded-corner buttons have shadows that still have corners.
也就是说,我的圆角按钮具有仍然有角的阴影。 I am not sure exactly why this may be the case.
我不确定为什么会出现这种情况。 I have followed the Defining Shadows and Clipping Views tutorial, but have not managed to solve the problem.
我已经按照定义阴影和剪辑视图教程,但没有设法解决问题。
So here is what I currently have. 所以这就是我现在所拥有的。 The light appears to be aimed downwards and to the left.
光似乎是向下和向左瞄准。 I can see that the corners are indeed rounded, but the shadows are not.
我可以看到角落确实是圆的,但阴影不是。 Looking closely at the bottom left corner of each button, I can see that the button is rounded, but there is a little piece of background with a corner still attached.
仔细观察每个按钮的左下角,我可以看到按钮是圆形的,但是有一小块背景,角落仍然附着。 All buttons have an elevation of 2dp.
所有按钮的高度均为2dp。 I am not sure how to remove this tiny piece of background.
我不知道如何删除这一小块背景。
Here is what the xml looks like: 这是xml的样子:
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_gravity="center">
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/standard_button_selector"
android:elevation="2dp"
android:layout_marginBottom="1dp"
/>
This uses a background selector: 这使用背景选择器:
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_pressed="true">
<shape
android:shape="rectangle">
<solid
android:color="@drawable/button_standard_pressed" />
<corners
android:radius="15dp" />
</shape>
</item>
<item android:state_focused="true" >
<shape
android:shape="rectangle">
<solid
android:color="@drawable/button_standard_focused"/>
<corners
android:radius="15dp" />
</shape>
</item>
<item>
<shape
android:shape="rectangle">
<solid
android:color="@drawable/button_standard_default"/>
<corners
android:radius="15dp" />
</shape>
</item>
</selector>
Corners have a 15dp radius, and everything appears to look correct for everything except the shadows. 角落的半径为15dp,除阴影外,一切看起来都很正确。 How can I fix it?
我该如何解决?
EDIT: 编辑:
This was simply a problem with viewing the screen on Eclipse's Graphical Layout preview. 这只是在Eclipse的图形布局预览中查看屏幕的问题。 As soon as I loaded this up on an actual device, it worked.
只要我在实际设备上加载它,它就可以工作了。
This was simply a problem with viewing the screen on Eclipse's Graphical Layout preview. 这只是在Eclipse的图形布局预览中查看屏幕的问题。 As soon as I loaded this up on an actual device, it worked.
只要我在实际设备上加载它,它就可以工作了。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.