我想添加阴影并在我的按钮上有圆角,如CSS中的box-shadow和border radius如何在XML中执行此操作? XML代码:
<Button android:id="@+id/dummy_button"
style="?metaButtonBarButtonStyle"
android:layout_width="198dp"
android:layout_height="69dp"
android:layout_weight="1"
android:text="@string/dummy_button"
android:fontFamily="trebuchet ms"
android:clickable="true"
android:onClick="printStarter"
android:background="#8c96ff"
android:layout_gravity="center_horizontal|bottom" />
答案 0 :(得分:2)
Android开发人员指南详细指南:Shape Drawbables.
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<corners android:radius="3dp" />
<stroke android:width="5px" android:color="#1a1a1a" />
带阴影的按钮
<layer-list
xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@drawable/shadow"/>
<item
android:drawable="@drawable/button"
android:bottom="4px" />
</layer-list>
</shape>
请参阅此tutorial
答案 1 :(得分:0)
您可以使用XML,这里有一些链接: How to provide shadow to Button; http://zrgiu.com/blog/2011/01/making-your-android-app-look-better/。要么 您可以使用9patch图像:http://developer.android.com/tools/help/draw9patch.html