android控件——Button使用

来源:互联网 发布:快喵 mac 编辑:程序博客网 时间:2024/05/30 22:50

Button控件

一、功能简介:

Button是程序用于和用户进行交互的一个重要控件,相信你对这个控件已经是非常熟悉 了,因为我们在上一章用了太多次 Button

二、创建textView文件:

以下是在layout.xml布局文件中的创建testView空间的一段代码:
<LinearLayout     xmlns:android="http://schemas.android.com/apk/res/android"     android:layout_width="match_parent"     android:layout_height="match_parent"     android:orientation="vertical" >    <Button     android:id="@+id/button"     android:layout_width="match_parent"    android:layout_height="wrap_content"     android:text="Button" /> </LinearLayout>     

1. 属性说明:

1.1 android:id=”@+id/button” 指定id

1.2 android:layout_width=”match_parent” 指定宽度

1.3 android:layout_height=”wrap_content” 指定高度

1.4 android:text=”Button” 指定内容


问题:

app效果只出现了textView控件,而Button按钮不可见

原因:

布局属性android:orientation 设置成 "vertical",垂直分布即可
0 0