第一次写博客,把自己学到的一点一滴分享出来,方便别人借鉴,也有助于自己的学习。写的不好请见谅,正在进步中。
先看一下效果图
mainActivity中不需要增加什么代码,主要看main.xml中
<?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" tools:context="com.example.shurukuang.MainActivity"> <LinearLayout android:layout_marginTop="100dp" android:layout_centerHorizontal="true" android:layout_width="300dp" android:layout_height="wrap_content" android:background="@drawable/shape_tousu"