zoukankan      html  css  js  c++  java
  • 屏幕界面android学习笔记49_屏幕适配,根据不同手机屏幕大小适配软件界面

    PS:今天上午,非常郁闷,有很多简单基础的问题搞得我有些迷茫,哎,代码几天不写就忘。目前又不当COO,还是得用心记代码哦!

        2013/5/12
    49_屏幕适配
    -----------------------
    1.根据手机屏幕的巨细自动表现软件界面的巨细
    2.这里用480x320和320x240这两种屏幕巨细举例。
    ---------------------------------------------
    3.新建android项目:
    4.在res文件夹下面新建layout-480x320文件夹用来适配分辨率为480x320的屏幕
      注意这里命名的时候必须要大分辨率在前面也就是不可以写成320x480
    ----------------------------------------------------------------------
    5.当前当用户应用480x320分辨率的屏幕是系统会自动的匹配这个文件夹下的界面
    ---------------------------------------------------------------------------
    6.这里只建了480x320和320x240的界面,当用户的手机是800x480这种屏幕的时候,因为找不到
      适配界面,所以这时候表现layout里头的界面
    --------------------------------------------
    7.下面是项目所需的文件:
      2013/5/12
      /ScreenAdapter/res/layout-320x240/main.xml
      <?xml version="1.0" encoding="utf-8"?>
    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:orientation="vertical" >
    <!-- 这里是在垂直设置的线性布局中再套一个水平设置的线性布局 -->
        <TextView
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:text="@string/name" />

        <EditText
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            />

        每日一道理
    “一年之计在于春”,十几岁的年纪,正是人生的春天,别辜负了岁月老人的厚爱与恩赐。行动起来,播种梦想吧!

        <Button
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="@string/button"
                />
           
    </LinearLayout>
    ---------------------------------------------------
    /ScreenAdapter/res/layout-480x320/main.xml
    <?xml version="1.0" encoding="utf-8"?>
    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:orientation="vertical" >
    <!-- 这里是在垂直设置的线性布局中再套一个水平设置的线性布局 -->
        <LinearLayout
             android:layout_width="fill_parent"
         android:layout_height="wrap_content"
         android:orientation="horizontal"
            >
        <TextView
            android:layout_width="80dp"
            android:layout_height="wrap_content"
            android:text="@string/name" />

        <EditText
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            />
        </LinearLayout>
       
        <Button
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="@string/button"
                />
           
    </LinearLayout>
    ---------------------
    /ScreenAdapter/res/values/strings.xml
    <?xml version="1.0" encoding="utf-8"?>
    <resources>

        <string name="hello">Hello World, MainActivity!</string>
        <string name="app_name">ScreenAdapter</string>
        <string name="name">姓名</string>
        <string name="button">保存</string>

        </resources>
    --------------------------------
    8.分辨率参照:
      屏幕分辨率
    HVGA:320×480
    QVGA:240x320
    WQVGA400:240X400
    WQVAG432:240X432
    WVGA800: 480X800
    WVGA854: 480X854

        Android软件开发普遍支撑的机型:HTC G1,G2,G3,G4 和 Moto Droid
    -----------------------------------------------------------------

    文章结束给大家分享下程序员的一些笑话语录: 联想——对内高价,补贴对外倾销的伟大“民族”企业。

  • 相关阅读:
    org.json.JSONObject的optXXX方法
    android Fragment的数据传递
    android .9图片的制作
    android handler
    CSS中的!important属性用法
    JS中的prototype
    JavaScript 函数创建思想
    css笔记
    Frameset使用教程
    HDU 5536 Chip Factory 【01字典树删除】
  • 原文地址:https://www.cnblogs.com/xinyuyuanm/p/3074101.html
Copyright © 2011-2022 走看看