我试图继承Android布局xml中的样式。现在看起来像:
layout.xml:
<RelativeLayout
android:id="@id/btn"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:clickable="true"
style="@style/AppTheme.ButtonLayout">
<TextView
android:id="@id/btn_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
style="@style/AppTheme.ButtonLayout.TextView" />
</RelativeLayout>
Run Code Online (Sandbox Code Playgroud)
styles.xml:
<style name="AppTheme.ButtonLayout">
<item name="android:textViewStyle">@style/AppTheme.ButtonLayout.TextView</item>
</style>
<style name="AppTheme.ButtonLayout.TextView" parent="android:Widget.Holo.Light.TextView">
<item name="android:textColor">@android:color/white</item>
</style>
Run Code Online (Sandbox Code Playgroud)
我想摆脱styleTextView 的属性,但它应该继承RelativeLayout的外观。可能吗?
编辑:我希望此TextView 仅在具有@style/AppTheme.ButtonLayout样式的RelativeLayout中具有这种样式。当它在内部布局中没有这种样式时,它应该看起来像默认的Android TextView。
假设我们有3个类:
@Component
public class A {
}
@Component
public class B {
}
@Component
public class C {
@Autowired
public C(A a, B b) { }
}
Run Code Online (Sandbox Code Playgroud)
默认情况下,每个bean都会看到其他任何已定义的bean:
我要实现的是限制bean A的可见性:
我以为我可以创建两个上下文:common(仅包含A bean定义)和child上下文(可查看在第一个上下文中定义的所有bean)并声明其自己的bean(B和C)。不幸的是,我没有找到使用Java Config的任何方法。
您知道实现这种解决方案的任何方法吗?