zoukankan      html  css  js  c++  java
  • Android学习——day3

    项目中的资源

    res目录

    • 以drawable开头的文件用来放图片

    • 以mipmap开头的文件存放应用图标

    • 以values开头的文件夹存放字符串、样式、颜色等配置

    • layout文件夹存放布局文件

    1.说明

    drawable/mipmap-hdpi、drawable/mipmap-mdpi、drawable/mipmap-xhdpi、drawable/mipmap-xxhdpi、drawable/mipmap-xxhdpi里面存放不同分辨率的图片,程序运行时,自动根据当前运行设备分辨率高低选择加载哪个文件夹下的图片 ;如只有一张图片,可以放在drawable-xxhdpi文件夹下。


    2.引用的基本语法

    • 在代码中通过R.string.hello_world可以获得字符串的引用

    • 在XML中通过@string/hello_world可以获得字符串的引用

         其中string可以替换为drawable、mipmap或layout。


    3.例子

    在AndroidManifest.xml文件中

     1 <application
     2     android:allowBackup="true"
     3     android:icon="@mipmap/ic_launcher"
     4     android:label="@string/app_name"
     5     android:supportsRtl="true"
     6     android:theme="@style/AppTheme">
     7     <activity android:name=".HelloWorldActivity">
     8         <intent-filter>
     9             <action android:name="android.intent.action.MAIN" />
    10             <category android:name="android.intent.category.LAUNCHER" />
    11         </intent-filter>
    12     </activity>
    13 </application>
    •   android:icon="@mipmap/ic_launcher":指定了应用图标

    •   android:label="@string/app_name":指定了应用名称

    此后可以自行更改应用名称、文本内容等

     1 <?xml version="1.0" encoding="utf-8"?>
     2 <manifest xmlns:android="http://schemas.android.com/apk/res/android"
     3     package="com.example.a86147.helloworld">
     4 
     5     <application
     6         android:allowBackup="true"
     7         android:icon="@mipmap/ic_launcher"
     8         android:label="@string/app_name"
     9         android:supportsRtl="true"
    10         android:theme="@style/AppTheme">
    11         <activity android:name=".HelloWorldActivity">
    12             <intent-filter>
    13                 <action android:name="android.intent.action.MAIN" />
    14 
    15                 <category android:name="android.intent.category.LAUNCHER" />
    16             </intent-filter>
    17         </activity>
    18     </application>
    19 
    20 </manifest>

     

  • 相关阅读:
    01 用CE查找游戏基址
    过QQ游戏大厅的SX保护 Evil0r's Blog 博客频道 CSDN_NET
    CODE人物坐标
    显示Combobox1中怪物名称列表.txt
    模拟安键F5 SendKeys
    红蓝保护(按键模拟)
    喊话CALL
    CODE Unicode roleName_字符类型数据 人物名子
    显示人物主要信息
    捡物 call 代码注入
  • 原文地址:https://www.cnblogs.com/znjy/p/14279910.html
Copyright © 2011-2022 走看看