`
zhanglibin1986
  • 浏览: 385448 次
  • 性别: Icon_minigender_1
  • 来自: 北京
社区版块
存档分类
最新评论

Android零碎知识点

阅读更多
退出程序,可以直接杀死进程:
android.os.Process.killProcess(android.os.Process.myPid());


不再用USB线,直接用adb命令将apk  push到sdcard中;
#:adb push ./ /sdcard/install

将当前目录下的所有文件push到sdcard中install文件夹。

关于那些烦人的单位:

android:maxWidth
Since: API Level

An optional argument to supply a maximum width for this view. See {see android.widget.ImageView#setMaxWidth} for details.

Must be a dimension value, which is a floating point number appended with a unit such as "14.5sp". Available units are: px (pixels), dp (density-independent pixels), sp (scaled pixels based on preferred font size), in (inches), mm (millimeters).

This may also be a reference to a resource (in the form "@[package:]type:name") or theme attribute (in the form "?[package:][type:]name") containing a value of this type.

This corresponds to the global attribute resource symbol maxWidth.

<TextView  
			    android:layout_width="wrap_content" 
			    android:layout_height="wrap_content" 
			    android:text="专辑"
			    android:textSize="20sp"
	    		/>


<ImageButton
    	android:layout_width="100dip"
    	android:layout_height="50dip"
    	android:src="@android:drawable/sym_action_call" />


<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
	android:orientation="vertical"
	android:layout_width="match_parent" 
    android:layout_height="match_parent"
	android:paddingLeft="8dip"
	android:paddingRight="8dip">



<TextView
                    android:text="@string/table_layout_9_open_shortcut"
                    android:gravity="right"
                   [color=red] android:padding="3dip"[/color] />


<Gallery android:id="@+id/gallery"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:gravity="center_vertical"
        [color=red]android:spacing="16dp"[/color]
    />


Dimension
A dimension value defined in XML. A dimension is specified with a number followed by a unit of measure. For example: 10px, 2in, 5sp. The following units of measure are supported by Android:

dp 
Density-independent Pixels - an abstract unit that is based on the physical density of the screen. These units are relative to a 160 dpi screen, so one dp is one pixel on a 160 dpi screen. The ratio of dp-to-pixel will change with the screen density, but not necessarily in direct proportion. The compiler accepts both "dip" and "dp", though "dp" is more consistent with "sp". 
sp 
Scale-independent Pixels - this is like the dp unit, but it is also scaled by the user's font size preference. It is recommend you use this unit when specifying font sizes, so they will be adjusted for both the screen density and the user's preference. 
pt 
Points - 1/72 of an inch based on the physical size of the screen. 
px 
Pixels - corresponds to actual pixels on the screen. This unit of measure is not recommended because the actual representation can vary across devices; each devices may have a different number of pixels per inch and may have more or fewer total pixels available on the screen. 
mm 
Millimeters - based on the physical size of the screen. 
in 
Inches - based on the physical size of the screen. 
Note: A dimension is a simple resource that is referenced using the value provided in the name attribute (not the name of the XML file). As such, you can combine dimension resources with other simple resources in the one XML file, under one <resources> element.

file location: 
res/values/filename.xml
The filename is arbitrary. The <dimen> element's name will be used as the resource ID. 
resource reference: 
In Java: R.dimen.dimension_name
In XML: @[package:]dimen/dimension_name 
syntax: 
<?xml version="1.0" encoding="utf-8"?> 
<resources> 
    <dimen 
        name="dimension_name" 
        >dimension</dimen> 
</resources>elements: 
<resources> 
Required. This must be the root node. 
No attributes.

<dimen> 
A dimension, represented by a float, followed by a unit of measurement (dp, sp, pt, px, mm, in), as described above. 
attributes:

name 
String. A name for the dimension. This will be used as the resource ID. 
example: 
XML file saved at res/values/dimens.xml: 
<?xml version="1.0" encoding="utf-8"?> 
<resources> 
    <dimen name="textview_height">25dp</dimen> 
    <dimen name="textview_width">150dp</dimen> 
    <dimen name="ball_radius">30dp</dimen> 
    <dimen name="font_size">16sp</dimen> 
</resources>This application code retrieves a dimension:

Resources res = getResources(); 
float fontSize = res.getDimension(R.dimen.font_size);This layout XML applies dimensions to attributes:

<TextView 
    android:layout_height="@dimen/textview_height" 
    android:layout_width="@dimen/textview_width" 
    android:textSize="@dimen/sixteen_sp"/>


res/values/color.xml:

<?xml version="1.0" encoding="utf-8"?>
<resources>
    <drawable name="red">#7f00</drawable>
    <drawable name="blue">#770000ff</drawable>
    <drawable name="green">#7700ff00</drawable>
	<drawable name="yellow">#77ffff00</drawable>
	
	<drawable name="screen_background_black">#ff000000</drawable>
    <drawable name="translucent_background">#e0000000</drawable>
    <drawable name="transparent_background">#00000000</drawable>

    <color name="solid_red">#f00</color>
    <color name="solid_blue">#0000ff</color>
</resources>


程序异常终止的原因:
今天在程序中的switch中,忘写了一个break;程序经常莫名其妙的发生异常, 查看log信息也查不出来,后来看代码,才发现了这个漏掉的break~~
分享到:
评论

相关推荐

    基于Android的移动学习系统的设计与实现.pdf

    该系统的设计与实现主要基于Android客户端应用开发,涉及到移动学习、学习资源、设计与实现等方面的知识点。 一、移动学习系统的需求分析 移动学习系统的需求分析是进行设计与开发的重要工作,就是要清楚这个系统...

    基于Android手机电子书阅读器的设计与实现(完整资料).doc

    知识点: 1. 项目开发目标: * 项目来源:手机电子书阅读器属于自选项目,旨在解决人们在空余时间进行电子书阅读的需求。 * 发展目标:让用户可以把零碎的空余时间有效的利用到书籍的阅读上,并且用户在没有网路...

    微信小程序-开发经验总结

    (主要是从一个Android开发者的角度来述说的,可能比较零碎的一些知识点和经验,如果大家还有补充,欢迎) 总结 1:传参,方法判断 js中 方法中可以传递一个方法作为形参,在java中是不可以的。比如start项目中的 ...

    微信小程序 开发经验整理

    (主要是从一个Android开发者的角度来述说的,可能比较零碎的一些知识点和经验,如果大家还有补充,欢迎) 总结 1:传参,方法判断 js中 方法中可以传递一个方法作为形参,在java中是不可以的。比如start项目中的 ...

    计算机网络技术专业毕业论文题目.docx

    计算机网络技术专业毕业论文题目涵盖了多个方面的知识点,包括网络技术、数据分析、人工智能、云计算、网络安全等。 基于挪动互联网下打扮品牌的推行及使用研讨 在这个题目中,研究者可以探讨如何使用挪动互联网...

    基于微信小程序的护理学专有名词学习平台的设计.pdf

    根据提供的文件信息,以下是对【标题】和【描述】所涉及的知识点的详细阐述: 1. 微信小程序的概念与应用: 微信小程序是一种不需要下载安装即可使用的应用,它实现了“触手可及”的应用体验。用户扫一扫或搜索即可...

Global site tag (gtag.js) - Google Analytics