Android Studio开发之路(三)Button控件

Button控件

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content">
    <!-- Button控件,是TextView的子类,可以加文字,可以加图片,也可以两者都加
    -->
    <!-- 此为一个添加文字的基础按钮,
    任何控件中的文字一般都写到strings.xml中,然后通过“@strings/name”来调用
    -->
    <Button
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="@string/btnText"
        android:textSize="20sp"></Button>

    <!-- 此为一个添加图片的按钮,
-->
    <ImageButton
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:src="@drawable/okButton"></ImageButton>

    <!-- 此为一个添加图片和文字的按钮,
-->
    <Button
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="@string/btnText"
        android:textSize="20sp"
        android:drawableLeft="@drawable/okButton"></Button>

</LinearLayout>

在这里插入图片描述

猜你喜欢

转载自blog.csdn.net/qq_41104439/article/details/130823736