为什么线性布局不能具有样式属性

vns*_*tty 17 xml android android-layout

我为线性布局定义了一种样式,但在图形视图中看不到布局 main.xml


main.xml中.

<LinearLayout style="VerticalThemeLayoutInputs">
Run Code Online (Sandbox Code Playgroud)

styles.xml

<resources>
<style name="VerticalThemeLayoutInputs">
    <item name="android:background">#6699FF</item>
    <item name="android:layout_width">fill_parent</item>
    <item name="android:layout_height">fill_parent</item>

</style>
</resources>
Run Code Online (Sandbox Code Playgroud)

编辑:

但是下面的代码可以正常工作,但我不想要这个代码

<LinearLayout
android:background="#6699FF"
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
Run Code Online (Sandbox Code Playgroud)

趣味事实

我用了一个scrollview.在其中我放置了许多线性布局.布局属性几乎相同所以我决定有一个风格.但是发生了什么?布局在图形视图中不可见,但在模拟器中工作正常.

但实际上发生了什么?我认为这是由于Scroll视图.

Ste*_*ice 22

我想你想要的是什么style="@style/VerticalThemeLayoutInputs".

例如

<LinearLayout
    style="@style/VerticalThemeLayoutInputs">
Run Code Online (Sandbox Code Playgroud)