android 查看界面控件id

最常用的是用eclipse/as的ddms去查看控件id,


然后通过显示的界面去点击各个控件,右下角就会显示控件id了,这个在系统开发的时候对于快速定位界面在代码的位置很有帮助,通过找到界面id然后估计是在那个apk里面,然后用grep去找那个id就可以定位到具体的代码是那个类里面了。

补充:ddms缺点是不能获得systemui的状态栏和导航栏的控件id,这个就需要使用hierarchyviewer.bat去获得了,这个具体看id的办法百度一下都有,就不 具体描述了,因为有的客户提供样机的机器或者以前别人做过的需求是有客制化自己的状态栏和导航栏的,这个时候就可以通过控件id去定位修改的位置了

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
下面是一个简单的Android Studio控件登录界面的代码示例: ```xml <?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent"> <ImageView android:id="@+id/imageView" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_centerHorizontal="true" android:layout_marginTop="50dp" android:src="@drawable/ic_launcher"/> <EditText android:id="@+id/usernameEditText" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_below="@+id/imageView" android:layout_marginLeft="20dp" android:layout_marginRight="20dp" android:layout_marginTop="50dp" android:hint="Username" android:inputType="text"/> <EditText android:id="@+id/passwordEditText" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_below="@+id/usernameEditText" android:layout_marginLeft="20dp" android:layout_marginRight="20dp" android:layout_marginTop="20dp" android:hint="Password" android:inputType="textPassword"/> <Button android:id="@+id/loginButton" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_below="@+id/passwordEditText" android:layout_marginLeft="20dp" android:layout_marginRight="20dp" android:layout_marginTop="50dp" android:text="Login"/> </RelativeLayout> ``` 这个界面包含一个ImageView、两个EditText和一个Button。ImageView用于显示应用的图标,两个EditText用于输入用户名和密码,Button用于提交登录信息。 在Activity中,可以通过findViewById()方法获取这些控件,并添加事件监听器来响应用户的操作。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值