1
后搜索如何在Android的定制化合物成分很长一段时间,我得到了以下代码:定制复合组件设置样式
public class MyCustomView extends RelativeLayout {
...
LayoutInflater inflater = (LayoutInflater)
context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
inflater.inflate(R.layout.my_custom_view, this, true);
}
为了避免双重RelativeLayout的,我必须使用my_custom_view合并.XML:
<?xml version="1.0" encoding="utf-8"?>
<merge xmlns:android="http://schemas.android.com/apk/res/android">
...
</merge>
但我不能在合并标签中指定样式,我怎么能设置使用styles.xml定义的样式MyCustomView风格?这个要求看起来很常见,但即使在网络上花了很长时间,我也找不到答案。希望一些有经验的android开发人员能帮助我。 THX〜