`
h389301776
  • 浏览: 9335 次
  • 性别: Icon_minigender_1
  • 来自: 广州
社区版块
存档分类
最新评论

9.图片按钮imageButton

 
阅读更多

9.图片按钮imageButton

 

在按钮上使用图片。

掌握imageButton的使用:

内容:

  与按钮组件(Button)类似,在Android中又提供了一个图片按钮,可以直接使用imageButton定义,此类定义如下:

java.lang.Object

          android.view.View

                android.widget.ImageView

                      android.widget.ImageButton

Button类是TextView类的子类,表示文本的扩充。

imageButtonImageView类的子类,表示对图片的扩充。

既然是表示图片按钮,那么就一定需要图片,图片就一定要保存。

<?xml version="1.0" encoding="utf-8"?>

<LinearLayout

        xmlns:android="http://schemas.android.com/apk/res/android"

              android:orientation="vertical"

              android:layout_width="fill_parent"

              android:layout_height="fill_parent"

        >

    <ImageButton

            android:id="@+id/rig"

            android:layout_width=" wrap_content "

            android:layout_height="wrap_content"

            android:src="@drawable/woniu"   使用图片替代文字

            />

    <ImageButton

            android:id="@+id/wro"

            android:layout_width=" wrap_content "

            android:layout_height="wrap_content"

            android:src="@drawable/yang"   使用图片替代文字

            />

</LinearLayout>

 

 

现在的按钮上多了图片的显示,就是好看一些。

总结:

ImageButton可以以图片的形式设置按钮的风格。

TextViewButton的关系= ImageViewImageButton的关系。

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics