7

I wanna make something like this:

<style name="cardViewInfo">
    <item name="android:layout_marginLeft">@dimen/small_padding_card_view</item>
    <item name="android:layout_marginRight">@dimen/small_padding_card_view</item>
    <item name="android:layout_marginBottom">@dimen/small_padding_card_view</item>
    <item name="android:layout_marginTop">@dimen/large_padding_card_view</item>
    <item name="card_view:cardCornerRadius">2dp</item>
</style>

But I have problems with the name card_view thats is not definded, my question is if I can make something like on the layout's to use this namespace:

xmlns:card_view="http://schemas.android.com/apk/res-auto"

Best regards.

Vinicius DSL
  • 1,839
  • 1
  • 18
  • 26

1 Answers1

5

So, although this isn't exactly a custom style, it IS a property outside of the android xmlns (XML Namespace).

I found that this works for me.

<resources>
    <style name="StyleName" parent="CardView.Light">
        <item name="android:layout_width">match_parent</item>
        <item name="android:layout_height">wrap_content</item>
        <item name="android:elevation">50dp</item>
        <item name="android:paddingLeft">6dip</item>
        <item name="android:paddingRight">6dip</item>
        <item name="cardUseCompatPadding">true</item>
        <item name="cardBackgroundColor">#fff</item>
        <item name="cardCornerRadius">6dp</item>
    </style>
</resources>

If you have any other errors, can you please post them as an edit to your original question.

Tyler
  • 19,113
  • 19
  • 94
  • 151