作者热门文章
- iOS/Objective-C 元类和类别
- objective-c - -1001 错误,当 NSURLSession 通过 httpproxy 和/etc/hosts
- java - 使用网络类获取 url 地址
- ios - 推送通知中不播放声音
我想在代码中实现与此 xml 中相同的功能(此 ImageView 位于相对布局内):
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:src="@drawable/logo"/>
我知道如何设置布局宽度和高度,但不知道如何设置 layout_alignParentLeft="true"。
是否可以在代码中执行此操作?
最佳答案
RelativeLayout.LayoutParams params =
new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT,
RelativeLayout.LayoutParams.WRAP_CONTENT);
params.addRule(RelativeLayout.ALIGN_PARENT_LEFT, RelativeLayout.TRUE);
imageView.setLayoutParams(params);
关于android - 如何设置android :layout_alignParentLeft attribute to imageview in code?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4819923/
我想在代码中实现与此 xml 中相同的功能(此 ImageView 位于相对布局内): 我知道如何设置布局宽度和高度,但不知道如何设置 layou
我是一名优秀的程序员,十分优秀!