Android的风格:区别“的风格=" @android:款式/ XYZ"”和“风格="安卓?ATTR / XYZ"'?风格、款式、区别、QUOT

由网友(刺痛我的心)分享简介:我想风格的按钮看起来像我在Android全宽ICS风格简约的底部ButtonsViews 的。 I'm trying to style buttons to look like those I ask about in Android Full Width ICS style Minimalist Bottom Bu...

我想风格的按钮看起来像我在Android全宽ICS风格简约的底部ButtonsViews 的。

I'm trying to style buttons to look like those I ask about in Android Full Width ICS style Minimalist Bottom ButtonsViews.

我已经成功了,用下面的XML,有兴趣的:

I've succeeded, with the following xml for anyone interested:

<LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_gravity="bottom"
        android:divider="@android:drawable/divider_horizontal_dark"
        android:gravity="bottom"
        android:orientation="vertical"
        android:paddingTop="16dip"
        android:showDividers="beginning|end" >

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:measureWithLargestChild="true"
            android:orientation="horizontal"
            android:divider="@android:drawable/divider_horizontal_dark"
            android:showDividers="middle" >                             


            <Button
                android:id="@+id/cancel_button"
                style="?android:attr/buttonBarButtonStyle"
                android:layout_width="0dip"
                android:layout_height="wrap_content"
                android:layout_gravity="left"
                android:layout_weight="1"
                android:maxLines="2"
                android:text="@string/cancel_button" />

            <Button
                android:id="@+id/login_button"
                style="?android:attr/buttonBarButtonStyle"
                android:layout_width="0dip"
                android:layout_height="wrap_content"
                android:layout_gravity="right"
                android:layout_weight="1"
                android:filterTouchesWhenObscured="true"
                android:maxLines="2"
                android:text="@string/login_button" />

        </LinearLayout>
    </LinearLayout>

但有一个问题。 Eclipse内容辅助根本不知道发生了什么与以下资源分辨率:

One question though. The eclipse content assist has no idea what's happening with the following resource resolution:

风格=机器人:ATTR / buttonBarButtonStyle

我熟悉的典型的分辨率(这Eclipse的内容辅助是知道的)

I'm familiar with the typical resolution (which eclipse's content assist is aware of)

风格= @安卓/风格/...

......但我不清楚这两者之间的区别。这似乎是一些样式属性出现在一个而不是其他。例如,下面不能解决任何事情:

...but I'm not clear on the difference between the two. It seems like some style attributes appear in one but not the other. For instance, the following doesn't resolve to anything:

风格= @安卓ATTR / buttonBarStyle

和同样没有这样的:

风格=@安卓风格/ buttonBarStyle

所以我想两个问题:

为什么在资源引用语法区别? 为什么风格下生成的attr类的混乱miscategorization。 什么是即使用于再ATTR类别?

谢谢!

推荐答案

从另一个答案对SO(这里是意译)

From another answer on SO (paraphrased here):

在使用的ID前面的问号意味着你要访问一个风格的属性这是在一个风格的主题定义的,而不是硬编码的属性。

Using a question mark in front of an ID means that you want to access a style attribute that's defined in a style theme, rather than hardcoding the attribute.

把它作为废弃一个主题属性来获取它所指向的资源,而不是指属性本身。

Think of it as dereferencing a theme attribute to fetch the resource it points to rather than referring to the attribute itself.

引用样式属性

阅读全文

相关推荐

最新文章