android:修改从样式继承的属性
我定义了以下样式:android:修改从样式继承的属性,android,styles,inherited,Android,Styles,Inherited,我定义了以下样式: <style name="Activity"> <item name="android:layout_width">fill_parent</item> <item name="android:layout_height">fill_parent</item> <item name="android:background">@drawable/background</item
<style name="Activity">
<item name="android:layout_width">fill_parent</item>
<item name="android:layout_height">fill_parent</item>
<item name="android:background">@drawable/background</item>
<item name="android:orientation">vertical</item>
</style>
填补家长的空缺
填补家长的空缺
@可绘制/背景
竖的
但我想在布局中定义布局\u height=“wrap\u content”,继承其余属性:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
style="@style/Activity"
android:layout_height="wrap_content">
...
</LinearLayout>
...
但它会继续应用填充父高度
可能吗?有什么解决办法吗?你的新风格
<style name="Activity">
<item name="android:layout_width">fill_parent</item>
<item name="android:background">@drawable/background</item>
<item name="android:orientation">vertical</item>
填补家长的空缺
@可绘制/背景
竖的
填充父样式
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android” style="@style/Activity" android:layout_height="fill_parent”> </LinearLayout>
包装内容样式
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android” style="@style/Activity" android:layout_height="wrap_content">
如果要更改布局xml中的布局高度,则可能还必须设置布局宽度。这并不能解决我的问题!默认属性是android:layout\u height=“fill\u parent”,但我需要在一个布局中覆盖它。如果我采用您的解决方案,我必须在所有布局中定义它。我不知道是否没有任何解决方案,我必须这样做。