安卓APP——基础控件

一、4种基础控件

  • Button 按键
  • TextView 文本框
  • EditText 输入框
  • ImageView 图片,带边框的
<ImageButton 
	android:layout_width="wrap_content"
	android:layout_height="wrap_content"
	android:src="@drawable/bx2"
	/>

二、padding和margin

图大小不变,内外边框拉升
在这里插入图片描述

  • margin 外边框,上下左右
android:layout_marginRight="10dp"
android:layout_marginLeft="10dp"
android:layout_marginTop="10dp"
  • padding 文字和内边框距离
android:paddingTop="70dp"
android:paddingLeft="60dp"
android:paddingRight="60dp"

三、制作一个登录界面

每个控件设置:id,长宽,对齐,文本
在这里插入图片描述

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".MainActivity" >
    
    <ImageButton 
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:src="@drawable/bx2"
        android:paddingTop="70dp"
        android:paddingLeft="60dp"
        android:paddingRight="60dp"
        android:layout_marginLeft="4dp"
        />

	<RelativeLayout 
	    android:layout_width="350dp"
	    android:layout_height="130dp"
	    android:layout_centerInParent="true"
	    android:background="#ff0000"
	    >
	    
	    <TextView 
	        android:id="@+id/te1"
	        android:layout_width="wrap_content"
	        android:layout_height="wrap_content"
	        android:layout_marginRight="10dp"
	        android:layout_marginLeft="10dp"
	        android:layout_marginTop="10dp"
	        android:text="用户"
	        android:textSize="20dp"
	        android:background="#ffffff"
	        />
	    
	    <EditText 
	        android:id="@+id/ed1"
	        android:layout_width="280dp"
	        android:layout_height="33dp"
	        android:layout_marginTop="10dp"
	        android:layout_toRightOf="@id/te1"
	        />
	    
	    <TextView 
	        android:id="@+id/te2"
	        android:layout_width="wrap_content"
	        android:layout_height="wrap_content"
	        android:layout_below="@id/te1"
	        android:textSize="20dp"
	        android:layout_marginRight="10dp"
	        android:layout_marginLeft="10dp"
	        android:layout_marginTop="10dp"
	        android:textColor="#ffffff"
	        android:text="密码"
	        />
	    
	    <EditText 
	        android:id="@+id/ed2"
	        android:layout_width="280dp"
	        android:layout_height="33dp"
	        android:layout_toRightOf="@id/te2"
	        android:layout_below="@id/ed1"
	        />
	    
	    <Button 
	        android:id="@+id/aj1"
	        android:layout_width="wrap_content"
	        android:layout_height="wrap_content"
	        android:layout_below="@id/ed2"
	        android:layout_alignRight="@id/ed2"
	        android:layout_marginRight="20dp"
	        android:text="取消"
	        />
	    <Button 
	        android:layout_width="wrap_content"
	        android:layout_height="wrap_content"
	        android:layout_toLeftOf="@id/aj1"
	        android:layout_alignBottom="@id/aj1"
	        android:layout_marginRight="20dp"
	        android:text="确定"
	        />
	
	</RelativeLayout>
    
</RelativeLayout>

师承上官可编程 —— 陈立臣

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

dz小伟

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值