Welcome 微信登录

首页 / 操作系统 / Linux / Android界面开发的一些笔记

1. 使用系统自带的图标使用方式:Android.R.drawable.
文件路径:android-sdk-windowsdocsimagesicon_design在布局文件中使用:<menu xmlns:android="http://schemas.android.com/apk/res/android">
       
    <item android:id="@+id/player_menu_item" android:title="@string/player" android:icon="@drawable/ic_menu_player" />
    <item android:id="@+id/settings_menu_item" android:title="@string/settings" android:icon="@drawable/android:ic_menu_preferences"/>
    <item android:id="@+id/about_menu_item" android:title="@string/about" android:icon="@drawable/android:ic_menu_info_details" />
</menu>2. 布局文件中使用能够自适应不同分辨率的图片背景:把背景文件重新命名为 xxx.9.png的样式,然后用工具里面的draw9patch编辑图片,通过图片边缘的黑色线条来确定图片如何拉升3.layout 的属性中pandding  和margin的区别:padding的定义是: Padding is defined as space between the edges of the view and the view"s content. A views size will include it"s padding.即padding是view和view之间的空白间距,但是这个空白是属于view的边界内部的。margin的定义是:Specifies extra space of this view. This space is outside this view"s bounds.即margin就是在view的边界外面的空白距离比如下面一个layout的定义:<RelativeLayout android:id="@+id/RelativeLayout02"
            android:background="@drawable/login_back"
            android:paddingTop="10.0dip"
            android:paddingBottom="30.0dip"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_marginLeft="15.0dip"
            android:layout_marginTop="62.0dip"
            android:layout_marginRight="15.0dip">这个Relativelayout的大小包含了paddingTop的10个dip和paddingBottom的30个dip。但是layout大小本身不包含margin看来padding和margin的主要区别就是padding的填充空白在组件的内部。margin的填充空白在组件的外部。