首页 > 学院 > 开发设计 > 正文

(二)UI

2019-11-09 16:53:13
字体:
来源:转载
供稿:网友

布局属性:

android:gravity="center" 文字对齐方式android:hint="hello yangyang!" 输入框提示文字android:maxLines="2" 指定EditText最大行数android:visibility="visible" PRlgressBar的消失,可見,消失并且不占位## android:layout_gravity="center" ## 控件的对齐方式,当LinearLayout的排列方式是horizontal时,只有垂直方向上的对齐方式才会生效,因为此时水平方向上的长度是不固定的,没添加一个控件,水平方向上的长度都会改变,因而无法指定该方向上的对齐方式。android:layout_weight="1" 系统会先把LinearLayout下所有控件指定的layout_weight值相加得到一个总值,然后每个控件所占大小的比例就是用该控件的layout_weight值除以刚才算出的总值。因此如果想让editText占据屏幕宽度的3/5,Button占据屏幕宽度的2/5,只需要将EditText的layout_weight改成3,Button的layout——weight改成2android:layout_centerInParent="true" 位于父控件的中间android:layout_alignParentBottom="true" 位于父控件的下边android:layout_alignParentLeft="true 位于父控件的最左边android:layout_toLeftOf="@+id/btA" 位于某控件的左边android:layout_alignLeft="@+id/btA" b控件的左边缘与a控件的左边缘对齐

对话框

AlertDialog.Builder dialog = new AlertDialog.Builder( ThirdActivity.this); dialog.setTitle("你好吗?"); dialog.setMessage("...."); dialog.setCancelable(true); dialog.setPositiveButton("yes", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface arg0, int arg1) { Log.d(MainActivity.TAG, "yes..."); } }); //注意:DialogInterface.OnClickListener dialog.setNegativeButton("no", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface arg0, int arg1) { Log.d(MainActivity.TAG, "no..."); } }); //显示对话框 dialog.show();
发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表