English 中文(简体)
如何超越安乐图书馆项目界定的风格特征(或隐藏)?
原标题:How to override (or hide) style attributes defined in the Android library project?

我有一套类似的申请。 我为图书馆项目提取了共同资源和代码,其应用只是凌驾于他们需要的之上。 在我的图书馆,有以下风格:

<style name="ListItemText">
    <item name="android:layout_toRightOf">@id/preview_image</item>
    <item name="android:textStyle">bold</item>
    <item name="android:textSize">@dimen/previewTextSize</item>
</style>

As you can see it contains android:layout_toRightOf attribute as this style would be applied to the text in the ListView row which should be displayed to the right of the image in that row.
However in one of my applications I d like to display the text below the image. How the ListItemText style in that application should be defined to override android:layout_toRightOf attribute value and replace it with android:layout_below?

如果我将其定义为:

<style name="ListItemText">
    <item name="android:layout_below">@id/preview_image</item>
</style>

它展示了右边和形象的文字,有效地总结了图书馆和XML应用风格的属性。

p.s.: One possible solution of my issue would be to get rid of android:layout_toRightOf in the styles and move it to the layout xml instead. Then in the target application this layout can be redefined/overridden. But I m looking for style-based solution, since it could provide more simple and straightforward way of attribute overriding.
(I can also use the inherited style with the parent attribute, but this would again require layout overriding in the application, which I try to avoid).

最佳回答

如欲打听android:layout_toRightOf,请上@null。 如果贵方对<代码>ListItemText的风格下定义如下,它就应当按照你的愿望开展工作:

<style name="ListItemText">
    <item name="android:layout_toRightOf">@null</item>
    <item name="android:layout_below">@id/preview_image</item>
</style>
问题回答




相关问题
Creating a Style in code behind

Does anyone know how to create a wpf Style in code behind, I can t find anything on the web or MSDN docs. I have tried this but it is not working: Style s = new Style(typeof(TextBlock)); s....

WPF Custom Themes

I have a simple question which is giving me some difficulty. I have downloaded a custom them for WPF of the net. Now i want to apply this theme to my App instead of the default one. How do i do that,...

Is it sometimes bad to use <BR />?

Is it sometimes bad to use <BR/> tags? I ask because some of the first advice my development team gave me was this: Don t use <BR/> ; instead, use styles. But why? Are there negative ...

WPF - How to apply effect to a cropped image?

I have an Image being clipped like so: <Image Width="45" Grid.Column="0" Source="{Binding Photo}"> <Image.Clip> <RectangleGeometry Rect="0,0,45,55" RadiusX="8" RadiusY="8" /...

WPF ListView : Header styling

I want to have a ListView with columns and a particular style: The background for ALL column headers should be transparent except when the mouse is over in one of them. When this happends, the ...

热门标签