android控件——Button使用

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",垂直分布即可
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值