根据这个CommonsWare示例,我设法将我的RelativeLayout子类与我在xml布局中描述的具有合并根的布局合并.我唯一担心的是我无法在xml中描述我的RelativeLayout参数.
我的xml布局:
<?xml version="1.0" encoding="utf-8"?>
<merge xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:my="http://schemas.android.com/apk/res/hu.someproject"
android:layout_width="36dp"
android:layout_height="wrap_content"
android:layout_marginLeft="3dp"
android:layout_marginRight="3dp"
android:width="36dp" >
<RelativeLayout
android:id="@+id/upper_container"
style="?pretty_style"
android:layout_alignLeft="@+id/image_title"
android:layout_alignParentTop="true"
android:layout_alignRight="@+id/image_title"
android:layout_centerHorizontal="true" >
<View
android:id="@+id/upper_indicator"
android:layout_width="fill_parent"
android:layout_height="5dp"
android:layout_alignParentTop="true"
android:background="@color/mycolor" />
<TextView
android:id="@+id/text_degree"
style="?pretty_style"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:text="23°" />
</RelativeLayout>
<hu.MyView
android:id="@+id/image_title"
style="?my_image_title"
android:layout_below="@+id/upper_container"
android:layout_centerHorizontal="true"
my:myColor="#2f8741"/>
Run Code Online (Sandbox Code Playgroud)
我认为问题是合并标签的子节点发生合并,而不是合并本身.任何想法如何在合并中获取我的参数以影响我的RelativeLayout?
我的RelativeLayout子类,没有包声明和导入:
public class MyRelativeLayoutSubclass extends RelativeLayout {
public MyRelativeLayoutSubclass(Context context) {
super(context);
initTile(null);
}
public MyRelativeLayoutSubclass(Context context, AttributeSet attrs) {
super(context, attrs);
initTile(attrs);
}
public MyRelativeLayoutSubclass(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle); …Run Code Online (Sandbox Code Playgroud) 例如,我可以使用以下方法操作ADB调试:
Settings.Secure.putInt(getActivity().getContentResolver(),Settings.Secure.ADB_ENABLED, 1);
Run Code Online (Sandbox Code Playgroud)
是否可以以类似的方式启用"显示布局边界"选项?我一直无法找到任何文件.