android 外部启动activity,自定义action,action常量大全

简介:
从任意app,启动另外一个app的activity:
1.   Intent i = new Intent(); 
         ComponentName cn = new ComponentName("com.book.android2",  "com.book.android2.AndroidSearch"); 
         i.setComponent(cn); 
         i.setAction("android.intent.action.MAIN"); 
         startActivity(i); //or startActivityForResult(i, RESULT_OK); 
我用这种方法时,绝大部分应用可以启动,但是像RootExplorer却无法启动,出现FC对话框,因此建议使用下面这种方式:
2.   Intent it = new Intent("android.intent.action.MAIN");
it.setClassName("com.speedsoftware.rootexplorer","com.speedsoftware.rootexplorer.RootExplorer");
startActivity(it);

如果你需要启动一个你自己写的另一个app的activity,你可以在那个的menifest.xml里自定义activity的action:
< activity  android:name =" .MainActivity "  android:label =" @string/app_name " android:theme =" @android:style/Theme.Black.NoTitleBar.Fullscreen " >
<intent-filter>
  <action android:name=" com.qylk.call.main" />    <!-- 自定义的action-->
  <action android:name=" android.intent.action.MAIN" />
  <category android:name=" android.intent.category.LAUNCHER" />
  <category android:name=" android.intent.category.DEFAULT" /><!--必须加上这个,否则下面无法直接使用自定的action-->
  </intent-filter>
  </activity>

其他地方启动它: Intent it = new Intent(" com.qylk.call.main "); startActivity(it);

3.使用adb启动activity:
启动RootExolorer:
am start -a android.intent.action.MAIN -n com.speedsoftware.rootexplorer/.RootExplorer
启动系统设置:
am start -a android.settings.SETTINGS

(转载):android系统Action常量(其实不算全)
android intent和intent action大全 

1.从google搜索内容 
Intent intent = new Intent(); 
intent.setAction(Intent.ACTION_WEB_SEARCH); 
intent.putExtra(SearchManager.QUERY,"searchString") 
startActivity(intent); 

2.浏览网页 
Uri uri = Uri.parse("http://www.google.com"); 
Intent it  = new Intent(Intent.ACTION_VIEW,uri); 
startActivity(it); 

3.显示地图 
Uri uri = Uri.parse("geo:38.899533,-77.036476"); 
Intent it = new Intent(Intent.Action_VIEW,uri); 
startActivity(it); 

4.路径规划 
Uri uri = Uri.parse("http://maps.google.com/maps?f=dsaddr=startLat%20startLng&daddr=endLat%20endLng&hl=en"); 
Intent it = new Intent(Intent.ACTION_VIEW,URI); 
startActivity(it); 

5.拨打电话 
Uri uri = Uri.parse("tel:xxxxxx"); 
Intent it = new Intent(Intent.ACTION_DIAL, uri);   
startActivity(it); 
 //<uses-permission id="android.permission.CALL_PHONE" /> 


6.调用发短信的程序 
Intent it = new Intent(Intent.ACTION_VIEW);    
it.putExtra("sms_body", "The SMS text");    
it.setType("vnd.android-dir/mms-sms");    
startActivity(it); 

7.发送短信 
Uri uri = Uri.parse("smsto:0800000123");    
Intent it = new Intent(Intent.ACTION_SENDTO, uri);    
it.putExtra("sms_body", "The SMS text");    
startActivity(it); 

String body="this is sms demo"; 
Intent mmsintent = new Intent(Intent.ACTION_SENDTO, Uri.fromParts("smsto", number, null)); 
mmsintent.putExtra(Messaging.KEY_ACTION_SENDTO_MESSAGE_BODY, body); 
mmsintent.putExtra(Messaging.KEY_ACTION_SENDTO_COMPOSE_MODE, true); 
mmsintent.putExtra(Messaging.KEY_ACTION_SENDTO_EXIT_ON_SENT, true); 
startActivity(mmsintent); 

8.发送彩信 
Uri uri = Uri.parse("content://media/external/images/media/23");    
Intent it = new Intent(Intent.ACTION_SEND);    
it.putExtra("sms_body", "some text");    
it.putExtra(Intent.EXTRA_STREAM, uri);    
it.setType("image/png");    
startActivity(it); 

StringBuilder sb = new StringBuilder(); 
sb.append("file://"); 
sb.append(fd.getAbsoluteFile()); 
Intent intent = new Intent(Intent.ACTION_SENDTO, Uri.fromParts("mmsto", number, null)); 
// Below extra datas are all optional. 
intent.putExtra(Messaging.KEY_ACTION_SENDTO_MESSAGE_SUBJECT, subject); 
intent.putExtra(Messaging.KEY_ACTION_SENDTO_MESSAGE_BODY, body); 
intent.putExtra(Messaging.KEY_ACTION_SENDTO_CONTENT_URI, sb.toString()); 
intent.putExtra(Messaging.KEY_ACTION_SENDTO_COMPOSE_MODE, composeMode); 
intent.putExtra(Messaging.KEY_ACTION_SENDTO_EXIT_ON_SENT, exitOnSent); 
startActivity(intent); 

9.发送Email 
Uri uri = Uri.parse("mailto:xxx@abc.com"); 
Intent it = new Intent(Intent.ACTION_SENDTO, uri); 
startActivity(it); 

Intent it = new Intent(Intent.ACTION_SEND);    
it.putExtra(Intent.EXTRA_EMAIL, "me@abc.com");    
it.putExtra(Intent.EXTRA_TEXT, "The email body text");    
it.setType("text/plain");   
 
startActivity(Intent.createChooser(it, "Choose Email Client")); 
Intent it=new Intent(Intent.ACTION_SEND);      
String[] tos={"me@abc.com"};      
String[] ccs={"you@abc.com"};      
it.putExtra(Intent.EXTRA_EMAIL, tos);      
it.putExtra(Intent.EXTRA_CC, ccs);      
it.putExtra(Intent.EXTRA_TEXT, "The email body text");      
it.putExtra(Intent.EXTRA_SUBJECT, "The email subject text");      
it.setType("message/rfc822");      
startActivity(Intent.createChooser(it, "Choose Email Client"));    

Intent it = new Intent(Intent.ACTION_SEND);    
it.putExtra(Intent.EXTRA_SUBJECT, "The email subject text");    
it.putExtra(Intent.EXTRA_STREAM, "file:///sdcard/mysong.mp3");    
sendIntent.setType("audio/mp3");    
startActivity(Intent.createChooser(it, "Choose Email Client")); 

10.播放多媒体   
Intent it = new Intent(Intent.ACTION_VIEW); 
Uri uri = Uri.parse("file:///sdcard/song.mp3"); 
it.setDataAndType(uri, "audio/mp3"); 
startActivity(it); 

Uri uri = Uri.withAppendedPath(MediaStore.Audio.Media.INTERNAL_CONTENT_URI, "1");    
Intent it = new Intent(Intent.ACTION_VIEW, uri);    
startActivity(it); 

11.卸载
Uri uri = Uri.fromParts("package", strPackageName, null);    
Intent it = new Intent(Intent.ACTION_DELETE, uri);    
startActivity(it); 

12.安装
Uri installUri = Uri.fromParts("package", "xxx", null); 
returnIt = new Intent(Intent.ACTION_PACKAGE_ADDED, installUri); 

13. 打开照相机 
    Intent i = new Intent(Intent.ACTION_CAMERA_BUTTON, null); 
    this.sendBroadcast(i);
 
    long dateTaken = System.currentTimeMillis(); 
    String name = createName(dateTaken) + ".jpg"; 
    fileName = folder + name; 
    ContentValues values = new ContentValues(); 
    values.put(Images.Media.TITLE, fileName); 
    values.put("_data", fileName); 
    values.put(Images.Media.PICASA_ID, fileName); 
    values.put(Images.Media.DISPLAY_NAME, fileName); 
    values.put(Images.Media.DESCRIPTION, fileName); 
    values.put(Images.ImageColumns.BUCKET_DISPLAY_NAME, fileName); 
    Uri photoUri = getContentResolver().insert( 
                    MediaStore.Images.Media.EXTERNAL_CONTENT_URI, values); 
    Intent inttPhoto = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); 
    inttPhoto.putExtra(MediaStore.EXTRA_OUTPUT, photoUri); 
    startActivityForResult(inttPhoto, 10); 

14.从gallery选取图片 
  Intent i = new Intent(); 
  i.setType("image/*"); 
  i.setAction(Intent.ACTION_GET_CONTENT); 
  startActivityForResult(i, 11); 

15. 打开录音机 
   Intent mi = new Intent(Media.RECORD_SOUND_ACTION); 
   startActivity(mi); 

16.显示应用详细列表       
Uri uri = Uri.parse("market://details?id=app_id");         
Intent it = new Intent(Intent.ACTION_VIEW, uri);         
startActivity(it);         
     


17.寻找应用      
刚才找app id未果,结果发现用package name也可以 
Uri uri = Uri.parse("market://details?id=<packagename>"); 
这个简单多了 
 
Uri uri = Uri.parse("market://search?q=pname:pkg_name");         
Intent it = new Intent(Intent.ACTION_VIEW, uri);         
startActivity(it); 
     
18.打开联系人列表            
           Intent i = new Intent(); 
           i.setAction(Intent.ACTION_GET_CONTENT); 
           i.setType("vnd.android.cursor.item/phone"); 
           startActivityForResult(i, REQUEST_TEXT); 

            Uri uri = Uri.parse("content://contacts/people"); 
            Intent it = new Intent(Intent.ACTION_PICK, uri); 
            startActivityForResult(it, REQUEST_TEXT); 

20.调用系统编辑添加联系人(高版本SDK有效): 
Intent it = new Intent(Intent.ACTION_INSERT_OR_EDIT); 
                it.setType("vnd.android.cursor.item/contact"); 
                // it.setType(Contacts.CONTENT_ITEM_TYPE); 
                it.putExtra("name", "myName"); 
                it.putExtra(android.provider.Contacts.Intents.Insert.COMPANY,  "organization"); 
                it.putExtra(android.provider.Contacts.Intents.Insert.EMAIL, "email"); 
                it.putExtra(android.provider.Contacts.Intents.Insert.PHONE,"homePhone"); 
                it.putExtra( android.provider.Contacts.Intents.Insert.SECONDARY_PHONE, 
                                "mobilePhone"); 
                it.putExtra(  android.provider.Contacts.Intents.Insert.TERTIARY_PHONE, 
                                "workPhone"); 
                it.putExtra(android.provider.Contacts.Intents.Insert.JOB_TITLE,"title"); 
                startActivity(it); 

21.调用系统编辑添加联系人(全有效): 
Intent intent = new Intent(Intent.ACTION_INSERT_OR_EDIT); 
            intent.setType(People.CONTENT_ITEM_TYPE); 
            intent.putExtra(Contacts.Intents.Insert.NAME, "My Name"); 
            intent.putExtra(Contacts.Intents.Insert.PHONE, "+1234567890"); 
            intent.putExtra(Contacts.Intents.Insert.PHONE_TYPE, Contacts.PhonesColumns.TYPE_MOBILE); 
            intent.putExtra(Contacts.Intents.Insert.EMAIL, "com@com.com"); 
            intent.putExtra(Contacts.Intents.Insert.EMAIL_TYPE,                    Contacts.ContactMethodsColumns.TYPE_WORK); 
            startActivity(intent); 



23.最基本的share 信息的intent,可以传一段text信息到各个手机上已安装程序:如SMS,Email,sina微波,米聊,facebook,twitter等等 
            Intent it = new Intent(Intent.ACTION_SEND);     
    it.putExtra(Intent.EXTRA_TEXT, "The email subject text"); 
            it.setType("text/plain"); 
            startActivity(Intent.createChooser(it, "Choose Email Client")); 
          

intent action大全: 
ACTION_MAIN                         作为一个主要的进入口,而并不期望去接受数据 
ACTION_VIEW                         向用户去显示数据 
ACTION_ATTACH_DATA                  用于指定一些数据应该附属于一些其他的地方,例如,图片数据应该附属于联系人 
ACTION_EDIT                         访问已给的数据,提供明确的可编辑 
ACTION_PICK                         从数据中选择一个子项目,并返回你所选中的项目 
ACTION_CHOOSER                      显示一个activity选择器,允许用户在进程之前选择他们想要的 
ACTION_GET_CONTENT                  允许用户选择特殊种类的数据,并返回(特殊种类的数据:照一张相片或录一段音) 
ACTION_DIAL                         拨打一个指定的号码,显示一个带有号码的用户界面,允许用户去启动呼叫 
ACTION_CALL                         根据指定的数据执行一次呼叫(ACTION_CALL在应用中启动一次呼叫有缺陷,多数应用ACTION_DIAL,ACTION_CALL不能用在紧急呼叫上,紧急呼叫可以用ACTION_DIAL来实现) 
ACTION_SEND                         传递数据,被传送的数据没有指定,接收的action请求用户发数据 
ACTION_SENDTO                       发送一跳信息到指定的某人 
ACTION_ANSWER                       处理一个打进电话呼叫 
ACTION_INSERT                       插入一条空项目到已给的容器 
ACTION_DELETE                       从容器中删除已给的数据 
ACTION_RUN                          运行数据,无论怎么 
ACTION_SYNC                         同步执行一个数据 
ACTION_PICK_ACTIVITY                为已知的Intent选择一个Activity,返回选中的类 
ACTION_SEARCH                       执行一次搜索 
ACTION_WEB_SEARCH                   执行一次web搜索 
ACTION_FACTORY_TEST                 工场测试的主要进入点, 


标准的广播Actions 
ACTION_TIME_TICK                   当前时间改变,每分钟都发送,不能通过组件声明来接收,只有通过Context.registerReceiver()方法来注册 
ACTION_TIME_CHANGED                时间被设置 
ACTION_TIMEZONE_CHANGED            时间区改变 
ACTION_BOOT_COMPLETED              系统完成启动后,一次广播 
ACTION_PACKAGE_ADDED               一个新应用包已经安装在设备上,数据包括包名(最新安装的包程序不能接收到这个广播) 
ACTION_PACKAGE_CHANGED             一个已存在的应用程序包已经改变,包括包名 
ACTION_PACKAGE_REMOVED             一个已存在的应用程序包已经从设备上移除,包括包名(正在被安装的包程序不能接收到这个广播) 
ACTION_PACKAGE_RESTARTED           用户重新开始一个包,包的所有进程将被杀死,所有与其联系的运行时间状态应该被移除,包括包名(重新开始包程序不能接收到这个广播) 
ACTION_PACKAGE_DATA_CLEARED        用户已经清除一个包的数据,包括包名(清除包程序不能接收到这个广播) 
ACTION_BATTERY_CHANGED             电池的充电状态、电荷级别改变,不能通过组建声明接收这个广播,只有通过Context.registerReceiver()注册 
ACTION_UID_REMOVED     一个用户ID已经从系统中移除

android.intent.action.ALL_APPS
android.intent.action.ANSWER
android.intent.action.ATTACH_DATA
android.intent.action.BUG_REPORT
android.intent.action.CALL
android.intent.action.CALL_BUTTON
android.intent.action.CHOOSER
android.intent.action.CREATE_LIVE_FOLDER
android.intent.action.CREATE_SHORTCUT
android.intent.action.DELETE
android.intent.action.DIAL
android.intent.action.EDIT
android.intent.action.GET_CONTENT
android.intent.action.INSERT
android.intent.action.INSERT_OR_EDIT
android.intent.action.MAIN
android.intent.action.MEDIA_SEARCH
android.intent.action.PICK
android.intent.action.PICK_ACTIVITY
android.intent.action.RINGTONE_PICKER
android.intent.action.RUN
android.intent.action.SEARCH
android.intent.action.SEARCH_LONG_PRESS
android.intent.action.SEND
android.intent.action.SENDTO
android.intent.action.SET_WALLPAPER
android.intent.action.SYNC
android.intent.action.SYSTEM_TUTORIAL
android.intent.action.VIEW
android.intent.action.VOICE_COMMAND
android.intent.action.WEB_SEARCH
android.net.wifi.PICK_WIFI_NETWORK

SETTING:
android.settings.AIRPLANE_MODE_SETTINGS
android.settings.APN_SETTINGS
android.settings.APPLICATION_DEVELOPMENT_SETTINGS
android.settings.APPLICATION_SETTINGS
android.settings.BLUETOOTH_SETTINGS
android.settings.DATA_ROAMING_SETTINGS
android.settings.DATE_SETTINGS
android.settings.DISPLAY_SETTINGS
android.settings.INPUT_METHOD_SETTINGS
android.settings.INTERNAL_STORAGE_SETTINGS
android.settings.LOCALE_SETTINGS
android.settings.LOCATION_SOURCE_SETTINGS
android.settings.MANAGE_APPLICATIONS_SETTINGS
android.settings.MEMORY_CARD_SETTINGS
android.settings.NETWORK_OPERATOR_SETTINGS
android.settings.QUICK_LAUNCH_SETTINGS
android.settings.SECURITY_SETTINGS
android.settings.SETTINGS
android.settings.SOUND_SETTINGS
android.settings.SYNC_SETTINGS
android.settings.USER_DICTIONARY_SETTINGS
android.settings.WIFI_IP_SETTINGS
android.settings.WIFI_SETTINGS
android.settings.WIRELESS_SETTINGS

在android SDK文档中有这样一个类,android.provider.Settings类提供android系统各个页面的跳转常量:
使用实例例:startActivity(new Intent(Settings.ACTION_WIRELESS_SETTINGS)),即可跳到android手机网络设置页面。
如果要launch Mobile Networks Setting页面按如下方法:
Intent intent=new Intent(Settings.ACTION_DATA_ROAMING_SETTINGS);
ComponentName cName = new ComponentName(“com.android.phone”,”com.android.phone.Settings”);
intent.setComponent(cName);
startActivity(intent);

如果要进入Networks Operators页面按如下方法:
Intent intent = new Intent(Intent.ACTION_MAIN);
intent.setClassName(“com.android.phone”, “com.android.phone.NetworkSetting”);
startActivity(intent);

String ACTION_ACCESSIBILITY_SETTINGS
辅助功能模块的显示设置。 Activity Action: Show settings for accessibility modules.
String ACTION_ADD_ACCOUNT
显示屏幕上创建一个新帐户添加帐户。 Activity Action: Show add account screen for creating a new account.
String ACTION_AIRPLANE_MODE_SETTINGS
显示设置,以允许进入/退出飞行模式。 Activity Action: Show settings to allow entering/exiting airplane mode.
String ACTION_APN_SETTINGS
显示设置,以允许配置的APN。 Activity Action: Show settings to allow configuration of APNs.
String ACTION_APPLICATION_DETAILS_SETTINGS
有关特定应用程序的详细信息的显示屏幕。 Activity Action: Show screen of details about a particular application.
String ACTION_APPLICATION_DEVELOPMENT_SETTINGS
显示设置,以允许应用程序开发相关的设置配置 Activity Action: Show settings to allow configuration of application development-related settings.
String ACTION_APPLICATION_SETTINGS
显示设置,以允许应用程序相关的设置配置 Activity Action: Show settings to allow configuration of application-related settings.
String ACTION_BLUETOOTH_SETTINGS
显示设置,以允许蓝牙配置 Activity Action: Show settings to allow configuration of Bluetooth.
String ACTION_DATA_ROAMING_SETTINGS
选择of2G/3G显示设置 Activity Action: Show settings for selection of2G/3G.
String ACTION_DATE_SETTINGS
显示日期和时间设置,以允许配置 Activity Action: Show settings to allow configuration of date and time.
String ACTION_DEVICE_INFO_SETTINGS
显示一般的设备信息设置(序列号,软件版本,电话号码,等) Activity Action: Show general device information settings (serial number, software version, phone number, etc.).
String ACTION_DISPLAY_SETTINGS
显示设置,以允许配置显示 Activity Action: Show settings to allow configuration of display.
String ACTION_INPUT_METHOD_SETTINGS
特别配置的输入方法,允许用户启用输入法的显示设置 Activity Action: Show settings to configure input methods, in particular allowing the user to enable input methods.
String ACTION_INPUT_METHOD_SUBTYPE_SETTINGS
显示设置来启用/禁用输入法亚型 Activity Action: Show settings to enable/disable input method subtypes.
String ACTION_INTERNAL_STORAGE_SETTINGS
内部存储的显示设置 Activity Action: Show settings for internal storage.
String ACTION_LOCALE_SETTINGS
显示设置,以允许配置的语言环境 Activity Action: Show settings to allow configuration of locale.
String ACTION_LOCATION_SOURCE_SETTINGS
显示设置,以允许当前位置源的配置 Activity Action: Show settings to allow configuration of current location sources.
String ACTION_MANAGE_ALL_APPLICATIONS_SETTINGS
显示设置来管理所有的应用程序 Activity Action: Show settings to manage all applications.
String ACTION_MANAGE_APPLICATIONS_SETTINGS
显示设置来管理安装的应用程序 Activity Action: Show settings to manage installed applications.
String ACTION_MEMORY_CARD_SETTINGS
显示设置为存储卡存储 Activity Action: Show settings for memory card storage.
String ACTION_NETWORK_OPERATOR_SETTINGS
选择网络运营商的显示设置 Activity Action: Show settings for selecting the network operator.
String ACTION_PRIVACY_SETTINGS
显示设置,以允许配置隐私选项 Activity Action: Show settings to allow configuration of privacy options.
String ACTION_QUICK_LAUNCH_SETTINGS
显示设置,以允许快速启动快捷键的配置 Activity Action: Show settings to allow configuration of quick launch shortcuts.
String ACTION_SEARCH_SETTINGS
全局搜索显示设置 Activity Action: Show settings for global search.
String ACTION_SECURITY_SETTINGS
显示设置,以允许配置的安全性和位置隐私 Activity Action: Show settings to allow configuration of security and location privacy.
String ACTION_SETTINGS
显示系统设置 Activity Action: Show system settings.
String ACTION_SOUND_SETTINGS
显示设置,以允许配置声音和音量 Activity Action: Show settings to allow configuration of sound and volume.
String ACTION_SYNC_SETTINGS
显示设置,以允许配置同步设置 Activity Action: Show settings to allow configuration of sync settings.
String ACTION_USER_DICTIONARY_SETTINGS
显示设置来管理用户输入字典 Activity Action: Show settings to manage the user input dictionary.
String ACTION_WIFI_IP_SETTINGS
显示设置,以允许配置一个静态IP地址的Wi – Fi Activity Action: Show settings to allow configuration of a static IP address for Wi-Fi.
String ACTION_WIFI_SETTINGS
显示设置,以允许Wi – Fi配置 Activity Action: Show settings to allow configuration of Wi-Fi.
String ACTION_WIRELESS_SETTINGS
显示设置,以允许配置,如Wi – Fi,蓝牙和移动网络的无线控制 Activity Action: Show settings to allow configuration of wireless controls such as Wi-Fi, Bluetooth and Mobile networks.
String AUTHORITY
String EXTRA_AUTHORITIES
在推出活动的基础上给予的权力限制可选项。 Activity Extra: Limit available options in launched activity based on the given authority.
String EXTRA_INPUT_METHOD_ID
相关文章
|
7月前
|
Android开发 UED 计算机视觉
Android自定义view之线条等待动画(灵感来源:金铲铲之战)
本文介绍了一款受游戏“金铲铲之战”启发的Android自定义View——线条等待动画的实现过程。通过将布局分为10份,利用`onSizeChanged`测量最小长度,并借助画笔绘制动态线条,实现渐变伸缩效果。动画逻辑通过四个变量控制线条的增长与回退,最终形成流畅的等待动画。代码中详细展示了画笔初始化、线条绘制及动画更新的核心步骤,并提供完整源码供参考。此动画适用于加载场景,提升用户体验。
548 5
Android自定义view之线条等待动画(灵感来源:金铲铲之战)
|
7月前
|
Android开发
Android自定义view之利用PathEffect实现动态效果
本文介绍如何在Android自定义View中利用`PathEffect`实现动态效果。通过改变偏移量,结合`PathEffect`的子类(如`CornerPathEffect`、`DashPathEffect`、`PathDashPathEffect`等)实现路径绘制的动态变化。文章详细解析了各子类的功能与参数,并通过案例代码展示了如何使用`ComposePathEffect`组合效果,以及通过修改偏移量实现动画。最终效果为一个菱形图案沿路径运动,源码附于文末供参考。
135 0
|
7月前
|
Android开发 开发者
Android自定义view之利用drawArc方法实现动态效果
本文介绍了如何通过Android自定义View实现动态效果,重点使用`drawArc`方法完成圆弧动画。首先通过`onSizeChanged`进行测量,初始化画笔属性,设置圆弧相关参数。核心思路是不断改变圆弧扫过角度`sweepAngle`,并调用`invalidate()`刷新View以实现动态旋转效果。最后附上完整代码与效果图,帮助开发者快速理解并实践这一动画实现方式。
192 0
|
7月前
|
Android开发 数据安全/隐私保护 开发者
Android自定义view之模仿登录界面文本输入框(华为云APP)
本文介绍了一款自定义输入框的实现,包含静态效果、hint值浮动动画及功能扩展。通过组合多个控件完成界面布局,使用TranslateAnimation与AlphaAnimation实现hint文字上下浮动效果,支持密码加密解密显示、去除键盘回车空格输入、光标定位等功能。代码基于Android平台,提供完整源码与attrs配置,方便复用与定制。希望对开发者有所帮助。
136 0
|
7月前
|
XML Java Android开发
Android自定义view之网易云推荐歌单界面
本文详细介绍了如何通过自定义View实现网易云音乐推荐歌单界面的效果。首先,作者自定义了一个圆角图片控件`MellowImageView`,用于绘制圆角矩形图片。接着,通过将布局放入`HorizontalScrollView`中,实现了左右滑动功能,并使用`ViewFlipper`添加图片切换动画效果。文章提供了完整的代码示例,包括XML布局、动画文件和Java代码,最终展示了实现效果。此教程适合想了解自定义View和动画效果的开发者。
358 65
Android自定义view之网易云推荐歌单界面
|
7月前
|
XML 前端开发 Android开发
一篇文章带你走近Android自定义view
这是一篇关于Android自定义View的全面教程,涵盖从基础到进阶的知识点。文章首先讲解了自定义View的必要性及简单实现(如通过三个构造函数解决焦点问题),接着深入探讨Canvas绘图、自定义属性设置、动画实现等内容。还提供了具体案例,如跑马灯、折线图、太极图等。此外,文章详细解析了View绘制流程(measure、layout、draw)和事件分发机制。最后延伸至SurfaceView、GLSurfaceView、SVG动画等高级主题,并附带GitHub案例供实践。适合希望深入理解Android自定义View的开发者学习参考。
697 84
|
7月前
|
Android开发 开发者
Android自定义View之不得不知道的文件attrs.xml(自定义属性)
本文详细介绍了如何通过自定义 `attrs.xml` 文件实现 Android 自定义 View 的属性配置。以一个包含 TextView 和 ImageView 的 DemoView 为例,讲解了如何使用自定义属性动态改变文字内容和控制图片显示隐藏。同时,通过设置布尔值和点击事件,实现了图片状态的切换功能。代码中展示了如何在构造函数中解析自定义属性,并通过方法 `setSetting0n` 和 `setbackeguang` 实现功能逻辑的优化与封装。此示例帮助开发者更好地理解自定义 View 的开发流程与 attrs.xml 的实际应用。
207 2
Android自定义View之不得不知道的文件attrs.xml(自定义属性)
|
缓存 前端开发 Android开发
安卓开发中的自定义视图:从零到英雄
【10月更文挑战第42天】 在安卓的世界里,自定义视图是一块画布,让开发者能够绘制出独一无二的界面体验。本文将带你走进自定义视图的大门,通过深入浅出的方式,让你从零基础到能够独立设计并实现复杂的自定义组件。我们将探索自定义视图的核心概念、实现步骤,以及如何优化你的视图以提高性能和兼容性。准备好了吗?让我们开始这段创造性的旅程吧!
207 1
|
7月前
|
前端开发 Android开发 UED
讲讲Android为自定义view提供的SurfaceView
本文详细介绍了Android中自定义View时使用SurfaceView的必要性和实现方式。首先分析了在复杂绘制逻辑和高频界面更新场景下,传统View可能引发卡顿的问题,进而引出SurfaceView作为解决方案。文章通过Android官方Demo展示了SurfaceView的基本用法,包括实现`SurfaceHolder.Callback2`接口、与Activity生命周期绑定、子线程中使用`lockCanvas()`和`unlockCanvasAndPost()`方法完成绘图操作。
216 3
|
7月前
|
Android开发 开发者
Android自定义view之围棋动画(化繁为简)
本文介绍了Android自定义View的动画实现,通过两个案例拓展动态效果。第一个案例基于`drawArc`方法实现单次动画,借助布尔值控制动画流程。第二个案例以围棋动画为例,从简单的小球直线运动到双向变速运动,最终实现循环动画效果。代码结构清晰,逻辑简明,展示了如何化繁为简实现复杂动画,帮助读者拓展动态效果设计思路。文末提供完整源码,适合初学者和进阶开发者学习参考。
144 0
Android自定义view之围棋动画(化繁为简)