android 的界面 都是.xml文件 存放在 res/layout里 要做界面首先需要懂得 LinearLayout线性布局,有两种格式
 
 
 
android :orientation= "vertical"
     
android :orientation= "horizontal" 指定宽度和高度的 wrap_parent match_parent //这里就不讲fill_parent,只要理解为match_parent的功能比fill_parent更好就行了 1.首先看图理解下什么是父节点和子节点 android基础-界面代码_第1张图片
wrap_parent :子节点有多大,父节点就有多大(父节点会根据子节点的大小调节自己的大小) match_parent:父容器有多大,子节点就有多大。(父节点不会因为子节点的大小二人改变自己的大小) 另外,如果不想用这些关键词,你还可以利用 android :layout_width= "500dp" 可以用dp单位自己指定大小!
这里是代码解释: <? xml version= "1.0" encoding= "utf-8" ?> //这句是必不可少的指定编码格式 < LinearLayout xmlns: android = "http://schemas.android.com/apk/res/android" //默认的不用理会 android :orientation= "vertical" //这里是决定这线性布局是横着的还是竖着的 xmlns: tools = "http://schemas.android.com/tools" android :id= "@+id/activity_main" //这里定义的是它对应的java文件 android :layout_width= "match_parent" //这里定义的是它的宽度 和高度 android :layout_height= "match_parent" //这下面的暂时不用管,因为你如果要增加一个组件的话只要定义它的宽和高就可以让他正常的显示了 android :paddingBottom= "@dimen/activity_vertical_margin" android :paddingLeft= "@dimen/activity_horizontal_margin" android :paddingRight= "@dimen/activity_horizontal_margin" android :paddingTop= "@dimen/activity_vertical_margin" tools :context= "com.example.asus.uidesigner.MainActivity" > LinearLayout >
接下来再告诉你可以调节占有界面比例的解释 先看效果 android基础-界面代码_第2张图片
<? xml version= "1.0" encoding= "utf-8" ?> < LinearLayout xmlns: android = "http://schemas.android.com/apk/res/android" android :orientation= "horizontal" xmlns: tools = "http://schemas.android.com/tools" android :id= "@+id/activity_main" android :layout_weight= "9" //指定比例 sum android :layout_width= "match_parent" android :layout_height= "match_parent"
tools :context= "com.example.asus.uidesigner.MainActivity" > < Button android :layout_weight= "3" //指定占有界面的比例 android :layout_height= "match_parent" android :layout_width= "0dp" //宽度的比例要将原来你设定的比例设置为0dp android :text= "y" android :textSize= "30dp" /> < Button android :layout_weight= "3" //指定占有界面的比例 android :layout_height= "match_parent" android :layout_width= "0dp" android :text= "s" android :textSize= "30dp" />
< Button android :layout_weight= "3.09" //指定占有界面的比例 android :layout_height= "match_parent" android :layout_width= "0dp" android :text= "p" android :textSize= "30dp" />
LinearLayout >

更多相关文章

  1. 通過android selector改变界面状态
  2. Android中弹出输入法界面不影响app界面布局
  3. Android中要让一个程序的界面始终保持一个方向(禁止转屏)
  4. Android——界面布局
  5. 修改Android解锁界面
  6. Android 特殊界面效果之——透明界面
  7. android打开系统联系人界面
  8. 在Android中实现service动态更新UI界面
  9. Android中应用界面主题Theme使用方法和页面定时跳转应用

随机推荐

  1. android之Activity
  2. Android(安卓)C/C++开发指南
  3. android自定义控件:可旋转View:可作为Image
  4. Android软件安全开发实践(下)
  5. Android官方刷新组件 SwipeRefreshLayout
  6. [Android]iTextG与SpongyCastle踩坑经历
  7. Android(安卓)基本按钮
  8. Android流式布局实现
  9. Android(安卓)Studio 编译报错:Manifest m
  10. android中Invalidate和postInvalidate的