首页 > 其他分享 >UI组件

UI组件

时间:2022-10-20 17:35:41浏览次数:84  
标签:文本框 UI 组件 编辑框 id 输入

UI组件

基本UI组件

  • 文本组件
  • 按钮组件
  • 日期 时间类组件 ImageView

文本框语法

用于显示文本信息

属性

<TextView
	android: layout_width="wrap_content"  
	android: layout_height="wrap_content"
	android:textSize = "16sp"
	android:textColor = "#FF5500"  这一行代码的最前面会有一个色块,可以选择颜色
	
	android:singleLine="true"    文本框一行无法显示的时候,会自动多行显示
	android:text="Hello Wor1d!"/>
我们也可以设定为一个文本框只能留一行,设置成单行文本框

wrap_content 包裹内容,布局根据内容大小来定。

引用value中的字符来显示

res/values/strings.xml这里面

resources>
<string name="app_name" >Demo</string>
<string name=" fendou">奋斗/string>
</resources>

activity_main中

<TextView
	android: layout_width="wrap_content"  
	android: layout_height="wrap_content"
	android:text="@string/fendou"/>

编辑框组件

match_parent与屏幕一样宽

hint 提示输入信息

inputType设定输入类型,textPassword时输入时转化为*,值为number时只能输入数字

<EditText   	
	android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:hint="请输入名称”
    android:inputType="textPassword"
    android:drawableLeft="mipmap/pic1" 
    android:lines="2" 让这个占2行/>
文字的间距调整:多行在一个框内,那就不方便控制了不美观

在编辑框内绘制图像,根据方位的不同:

  • drawableBottom
  • drawableRight == drawableEnd
  • drawableLeft == drawableStart 后者适合高级版本
  • drawableTop

获取编辑框里面的内容

getText() ,需要在java的文件里面做,但是也需要在布局中给出其id

布局中

id = et1

java中

EditText et=(EditText)findViewById(R.id.et1);
et.getText();

05 编辑框的实例——实现布局手机QQ空间写说说页面_哔哩哔哩_bilibili

标签:文本框,UI,组件,编辑框,id,输入
From: https://www.cnblogs.com/tupo/p/16810600.html

相关文章