Android风格:与x27的区别;风格=“@android:style/XYZ“';和';style=";?android:attr/XYZ“';?
我正在尝试将按钮的样式设置为我在中询问的样式 我成功了,为感兴趣的人提供了以下xml:Android风格:与x27的区别;风格=“@android:style/XYZ“';和';style=";?android:attr/XYZ“';?,android,android-layout,android-resources,android-styles,Android,Android Layout,Android Resources,Android Styles,我正在尝试将按钮的样式设置为我在中询问的样式 我成功了,为感兴趣的人提供了以下xml: <LinearLayout android:layout_width="match_parent" android:layout_height="match_parent" android:layout_gravity="bottom" android:divider="@android:drawable/divider_horizonta
<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内容助手不知道以下资源解析发生了什么:
style=“?android:attr/buttonBarButtonStyle”
我熟悉典型的分辨率(eclipse的content assist知道这一点)
style=@android/style/…
…但我不清楚两者之间的区别。似乎有些样式属性出现在其中一个中,但在另一个中却没有。例如,以下内容不能解决任何问题:
style=@android:attr/buttonBarStyle
这也不是:
style=“@android:style/buttonBarStyle
我猜这里有两个问题:
?android:attr/buttonBarButtonStyle或只是?android:buttonBarButtonStyle(attr是可选的)
@android:style/Widget.Button
这将在内部取消对@android:style/Widget.Button的引用,该按钮在appcompat/res/values/themes.xml文件中定义
(?android:)-始终链接到当前应用主题的属性值。因此,我们只能引用android定义的样式,而不是创建新样式并提供硬编码的值
谷歌文档说,
<item name="buttonBarButtonStyle">@android:style/Widget.Button</item>