Android如何设置圆角按钮
1.在res目录下的drawable目录下新建shape.xml文件
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<!--填充的颜色-->
<solid android:color="#217EDA"></solid>
<!--设置按钮的四个角的弧度-->
<!--android:radius 弧度的半径-->
<corners android:radius="20dp"></corners>
<!--padding-->
<padding
android:bottom="10dp"
android:left="10dp"
android:right="10dp"
android:top="10dp">
</padding>
</shape>
2.在布局文件中调用
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity"
android:gravity="center">
<Button
android:text="圆角按钮"
android:background="@drawable/shape"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</LinearLayout>
nvisible:不显示,单保留所占空间
visible:正常显示
gone:不显示,而且不保留所占空间
XML中:
android:visibility=“visible”