• 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()

    继承自AlertDialog

  • RelativeLayout

    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"/>

最新文章

  1. find
  2. windows 自带的 端口映射 端口转向功能
  3. [I2C]I2C架构分析
  4. HDU 2571 命运
  5. 如何成为Python高手(转载)
  6. [转自Kevins的天空 http://rootsec.cn]rad studio 2007 up3方法
  7. Java 集合深入理解(10):Deque 双端队列
  8. VS2008使用技巧及快捷键大全
  9. Android Design Support Library: 学习CoordinatorLayout
  10. hadoop2.2.0的WordCount程序
  11. MySQL基本语法(一):和SQL Server语法的差异小归纳
  12. [转]USDT与omniCore钱包
  13. 【读书笔记】iOS-加速计与陀螺仪
  14. WEB服务器、应用程序服务器、HTTP服务器的区别
  15. hibernate cascade的真正含义
  16. System.Data.SQLite.dll控件常规安装方法
  17. mysql中如何不重复插入,mysql 重复的不插入,mysql唯一的插入
  18. Ryubook_1_switch_hub_部署执行
  19. pycharm 2018 3.4 for mac破解
  20. CSS3可伸缩框属性,可用于等分显示子元素或按比例显示子元素的大小

热门文章

  1. [转] 使用Spring Boot和Gradle创建项目
  2. linux中切换用户方式su和su -的区别
  3. URAL 1306 - Sequence Median 小内存求中位数
  4. Windows Media Player Plus
  5. nginx轮询配置详解
  6. MSSQL 简单练习回顾
  7. linux jdk,java ee ,tomcat 安装配置
  8. Mysql 视图笔记
  9. C/C++默认浮点型
  10. MySQL重构查询的方式