TextView控件常用属性:
android:id–控件的id
android:layout_width–控件宽度
android:layout_height–控件高度
warp_content:包裹实际文本内容,文本有多宽,它就有多宽
match_parent:当前控件铺面父类容器(2.3API之后添加的属性值)
fill_parent:当前控件铺满父类容器
(2.3API之前添加的属性值)
android:text–文本内容
android:textSize–文本大小
androif:textColor–文本颜色
android:background–控件背景
EditView控件除拥有TextView的常用属性外还有以下属性:
android:hint–输入提示文本
android:inputType:输入文本类型(例如:纯数字)

layout下建立一个main_activity.xml文件"@id/textView1"    android:layout_width="warp_content"    androidLlayout_height="warp_content"    android:text="姓名"    android:textSize="28sp"    android:textColor="#000000"    />
<EditText    android:text="abcd"    android:hint="请输入你的姓名"    android:id="@+id/editText1"    android:layout_width="match_parent"    android:layout_weight="warp_content">EditText>

src下建立MainActivity.java文件

public class MainActivity extends Activity{    @Override    protected void onCreate(Bundle savedInstanceState){    super.onCreate(savedInseanceState);    //将布局xml文件引入到activity中    setContenView(R.layout.main_activity);    }}
android:inputType="textPassword" //设置输入格式为密码格android:inputType="phone"  //设置输入格式为拨号键盘

ImageView控件用于显示图片
常用属性:

//ImageView的内容图像android:src="@drawable/ic_launcher"//ImageView背景图片android:background:"@drawable/ic_launcher"//设置ImageView的颜色android:background="#00ff00"

Button(按钮)与ImageButton(图片按钮)

Button有text属性,ImageButton没有。
ImageButton有src属性,Button没有。
.xml文件访问Strings.xml中的资源:
strings.xml

登陆

main.xml访问

<Buttonandroid:text="@string/button_name"/>/>

更多相关文章

  1. Android五大布局和ConstraintLayout
  2. android:hintText与android:inputType详解
  3. android:layout_weight之我见
  4. 【Android】第7章(2)--布局控件常用的公共属性
  5. Android(安卓)实现多行文本跑马灯效果
  6. Android(安卓)输入法键盘和activity页面遮挡问题解决
  7. Android(安卓)Layout XML属性
  8. android:inputType 属性及其支持的取值
  9. Android(安卓)动态设置TextView的drawableLeft等属性

随机推荐

  1. Android(安卓)-- service两种启动方式sta
  2. Android简易计算器——LinearLayout布局
  3. android 使用代码实现 RelativeLayout布
  4. android动效开篇
  5. Android ViewPager 中嵌套webview 的滚动
  6. android 登录Javaeye(使用HttpURLConnect
  7. Android app里打开proguard
  8. Android Frame Animation
  9. 在Android 7.0上PopupWindow.showAsDropD
  10. android用于定时任务工具类