Android教程網
  1. 首頁
  2. Android 技術
  3. Android 手機
  4. Android 系統教程
  5. Android 游戲

自定義帶圓角、黑色描邊、白色背景的背景樣式

編輯:關於 Android 開發

自定義帶圓角、黑色描邊、白色背景的背景樣式


首先在 drawable 文件夾下新建一個 xml 文件 solid_c9c9c9.xml:

<?xml version="1.0" encoding="utf-8"?> <shape xmlns:android="https://schemas.android.com/apk/res/android" android:shape="rectangle"><!--方形--> <stroke android:width="1dp" android:color="@color/color_c9c9c9" /><!--描邊--> <solid android:color="@color/white" /><!--背景--> <corners android:radius="5dp" /><!--圓角--> </shape>

然後在布局文件中直接引用這個 xml 作為背景即可:

<LinearLayout android:layout_width="match_parent" android:layout_height="40dp" android:orientation="horizontal" android:layout_margin="@dimen/padding_15" android:background="@drawable/solid_c9c9c9"> </LinearLayout>

效果圖:

  1. 上一篇文章:
  2. 下一篇文章:
Copyright © Android教程網 All Rights Reserved