界面布局:

<?xml version="1.0"encoding="utf-8"?>

<LinearLayoutxmlns:android="http://schemas.android.com/apk/res/android"

android:orientation="vertical"

android:layout_width="fill_parent"

android:layout_height="fill_parent" >

<TextView

android:layout_width="fill_parent"android:layout_height="wrap_content"

android:text="@string/inputmobile"/>

<EditTextandroid:layout_width="fill_parent"android:layout_height="wrap_content"

android:id="@+id/mobile"/>

<Buttonandroid:layout_width="wrap_content"android:layout_height="wrap_content"

android:text="@string/button"

android:id="@+id/button"/>

</LinearLayout>


AndroidManifest.xml中添加电话服务权限:<uses-permissionandroid:name="android.permission.CALL_PHONE"/>




Activity:

public class DialerAction extends Activity {

@Override

public void onCreate(BundlesavedInstanceState) {

super.onCreate(savedInstanceState);

setContentView(R.layout.main);

Button button =(Button)findViewById(R.id.button);

button.setOnClickListener(newView.OnClickListener(){

publicvoid onClick(View v) {

EditTexteditText = (EditText)findViewById(R.id.mobile);

Intentintent = new Intent(Intent.ACTION_CALL,Uri.parse("tel:"+editText.getText()));

DialerAction.this.startActivity(intent);

}

});

}

}

上面的数据来源于源码解读




删除呼叫记录

Android:电话拨号器、呼叫记录、结束通话、Android显示单位_第1张图片



Android:电话拨号器、呼叫记录、结束通话、Android显示单位_第2张图片36


Android中的显示单位


l px (pixels) 像素

一般HVGA代表320x480像素,这个用的比较多。

l dip dp (device independent pixels) 设备独立像素

这个和设备硬件有关,一般为了支持WVGAHVGAQVGA推荐使用这个,不依赖像素。

l sp (scaled pixels — best for textsize) 比例像素

主要处理字体的大小,可以根据系统的字体自适应。

除了上面三个显示单位,下面还有几个不太常用:

l in (inches) 英寸 l mm (millimeters) 毫米 l pt (points) 点, 1/72 英寸 l

为了适应不同分辨率,不同的像素密度,推荐使用dip,文字使用sp


更多相关文章

  1. android 手机判断是否在充电 如断电自动打电话提醒功能
  2. Android之简易电话 & 短信
  3. Android长度单位详解(dp、sp、px、in、pt、mm、dip)
  4. Android之路——第一个Android小程序(Android电话拨号器)
  5. Android - 像素密度和屏幕适配
  6. Android 自定义像素AVD模拟器无键盘

随机推荐

  1. Android SQLiter cursor的使用
  2. Ubuntu android studio 调试 android wea
  3. android中TextView中文字体粗体的方法 (a
  4. Configuration on demand is not support
  5. android使用两种方式注册receiver
  6. Android DEX方法超过64K和gradle编译OOM
  7. Android中汉字转拼音的内存优化处理
  8. actionbar与viewpager的联合使用(android
  9. android获取系统铃声并播放
  10. The Busy Coder's Guide to Android(安卓