原生控件

TextView

  • layout_width:
    • fill_parent(-1): The view should be as big as its parent (minus padding). This constant is deprecated starting from API Level 8 and is replaced by {@code match_parent}.
    • match_parent(-1): The view should be as big as its parent (minus padding). This constant is deprecated starting from API Level 8 and is replaced by {@code match_parent}.
    • wrap_content(-2): The view should be only big enough to enclose its content (plus padding).
  • layout_height:
    • 同layout_width
  • TextView
    • text:Text to display.
  • View: Attributes that can be used with {@link android.view.View} or any of its subclasses. Also see {@link #ViewGroup_Layout} for attributes that are processed by the view's parent.
    • id:Supply an identifier name for this view, to later retrieve it
    • background:A drawable to use as the background. color颜色表示方法
  • Theme
    • gravity: Specifies how an object should position its content, on both the X and Y axes, within its own bounds.
    • textStyle:
      • normal(0)
      • bold(1)
      • italic(2)
  • TextAppearance
    • shadowColor:Place a blurred shadow of text underneath the text, drawn with the specified color.
    • shadowRadius: Blur radius of the text shadow.
    • shadowDx:Horizontal offset of the text shadow.
    • shadowDy: Vertical offset of the text shadow.

  • textView获取聚焦的方法:
    • clickable —— 点击后聚焦
    • TextView标签内添加标签 —— 自动聚焦
    • 自定义View,isFocused返回true —— 自动聚焦

Button

  • Button属性
    • 更改button颜色是需要在themes文件中对parent字段加上.Bridge后缀
    • Button的background是一个选择器在不同状态下选择的内容如图所示
    • Button可视的内容从下到上依次是background,text,foreground,上层内容会将下层内容覆盖
  • Button事件处理
    • Button事件触发顺序: OnTouch → OnLongClick → OnClick,在任一环节事件被消费(回调方法返回true)之后的事件就不会触发
    • 触摸事件分为三种:ACTION_DOWN(0), ACTION_DOWN(1), ACTION_MOVE(2)
    • 在xml中可以直接使用onclick属性添加对应的方法来实现setOnClickListener

EditText

  • EditText属性
    • drawableLeft:在编辑框左侧添加图片
    • drawablePadding: 图片与输入文字的间距
    • hint:提示内容
    • inputType: 输入类型

ImageView

  • ImageView属性
    • scaleType:Controls how the image should be resized or moved to match the size of this ImageView. 详将下图:
    • maxHeigh,maxWidth,adjustViewBounds三个属性联和使用,图片宽或高达到最大后按照原图比例自适应ImageView缩放

ProgressBar

  • ProgressBar属性
    • style:进度条样式
    • max:Defines the maximum value.
    • progress:Defines the default progress value, between 0 and max.
    • indeterminate: Allows to enable the indeterminate mode. In this mode the progress bar plays an infinite looping animation.
posted @   怪客-3386  阅读(8)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 物流快递公司核心技术能力-地址解析分单基础技术分享
· .NET 10首个预览版发布:重大改进与新特性概览!
· 单线程的Redis速度为什么快?
· 展开说说关于C#中ORM框架的用法!
· Pantheons:用 TypeScript 打造主流大模型对话的一站式集成库
点击右上角即可分享
微信分享提示