Android笔记(三):View一些值得注意的地方
Button
android:textAllCaps="false" // Button上的英文字符不转成大写EditText
android:maxLines="2" // 指定EditText最大行数为2行,超过2行时文本向上滚动。ImageView
setImageResource(R.drawable.picture)ProgressBar
ProgressBar.getProgress()
ProgressBar.setProgress(int)
ProgressBar.setMax(int)AlertDialog
setCancelable(boolean)
setPositiveButton()
setNegativeButton()
show()ProgressDialog
setCancelable(boolean)
show()
继承自AlertDialogRelativeLayout
android:layout_centerInParent="true"
android:layout_alignLeft // 表示让一个控件的左边缘和另一个控件的左边缘对齐PercentFrameLayout
compile 'com.android.support:percent:25.1.0'<android.support.percent.PercentFrameLayout>
<android.support.percent.PercentRelativeLayout>
LinearLayout本身就有百分比,不需要再添加为了兼容低版本,使用xmlns:app
app:layout_widthPercent="50%"
用这个就不用再写android:layout_width在布局中引入其他布局文件
<include layout="@layout/toolbar" />
这样使得不必在每个Activity的界面都实现一遍这个布局。
padding 和 margin
<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"> <Button
android:id="@+id/btn_test"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="30dp"
android:padding="50dp"
android:text="@string/test"/> </RelativeLayout>
Android控件的三个属性
属性 说明 View.VISIBLE 可见 VIEW.INVISIBLE 不可见,但占据原来的位置 VIEW.GONE 完全消失 setVisibility(从上面三个选)
创建自定义控件
public class TitleLayout extends LinearLayout { public TitleLayout(Context context, AttributeSet attrs) {
super(context, attrs);
LayoutInflater.from(context).inflate(R.layout.title, this);
// 可以在这里注册布局内按钮的点击事件
}
}
<com.域名.包名.TitleLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
最新文章
- find
- windows 自带的 端口映射 端口转向功能
- [I2C]I2C架构分析
- HDU 2571 命运
- 如何成为Python高手(转载)
- [转自Kevins的天空 http://rootsec.cn]rad studio 2007 up3方法
- Java 集合深入理解(10):Deque 双端队列
- VS2008使用技巧及快捷键大全
- Android Design Support Library: 学习CoordinatorLayout
- hadoop2.2.0的WordCount程序
- MySQL基本语法(一):和SQL Server语法的差异小归纳
- [转]USDT与omniCore钱包
- 【读书笔记】iOS-加速计与陀螺仪
- WEB服务器、应用程序服务器、HTTP服务器的区别
- hibernate cascade的真正含义
- System.Data.SQLite.dll控件常规安装方法
- mysql中如何不重复插入,mysql 重复的不插入,mysql唯一的插入
- Ryubook_1_switch_hub_部署执行
- pycharm 2018 3.4 for mac破解
- CSS3可伸缩框属性,可用于等分显示子元素或按比例显示子元素的大小