41053

How do I inherit from default Android style in my custom styles.xml?

Question:

I am currently using this custom styles layout for my EditTexts defined in 'styles.xml':

<style name="Form_EditView"> <item name="android:textColor">@color/white</item> <item name="android:textSize">@dimen/large_text_size</item> <item name="colorControlNormal">@color/white</item> <item name="colorControlActivated">@color/pink</item> <item name="colorControlHighlight">@color/pink</item> </style>

However now my dilemma occurs as I have a TextView that I would like to be styled like a default Android EditText but then to also apply my above custom styling. The default Android style is the one displayed below:

style="@android:style/Widget.EditText"

I know that inheritance is possible in layout styles files but how do I go about inheriting from Android default styles in my custom styles, to achieve something similar to this:

<style name="Widget.EditText.Form_EditView">

Answer1:

The simplest way to inherit some other style - is to use parent attribute:

<style name="Form_EditView" parent="@android:style/Widget.EditText">

As @Bobby StJacques pointed out, if you want to inherit styles <strong>you defined</strong> (not built-in Android ones), you can use the following form:

<style name="Form_EditView.SomeCustomizedEditView"> .... </style>

In this case you inherit your already defined Form_EditView

Recommend

  • assign unique ID to each unique value in group after pandas groupby
  • Convert strings to dates and delete non-dates in one column of a data frame
  • Android permissions categories and DELETE_PACKAGES and INSTALL_PACKAGES permissions
  • NewEgg API access for price, inventory (JSON/XML) [closed]
  • Defining 4-byte UTF-16 character in a string
  • How is strcpy implemented?
  • 0% accuracy with evaluate_generator but 75% accuracy during training with same data - what is going
  • Update Eclipse menu item enabled state
  • Why doesn't the /reference option to svcutil.exe work?
  • invoke Matlab object's (directory) method from .Net
  • PHP float modulus not working
  • gcc suppress warning “too small to hold all values of”
  • Nuget not reinstalling packages
  • R: gsub in a loop to replace names
  • Set div block to 100% height
  • Makefile Argument string comparision
  • Cassandra OperationTimedOut
  • Extracting table data from a website using R [closed]
  • Unit testing NgRx effect to ensure the service method was called - ain't working
  • Send objects from flex to java servlet
  • How to parse a variable number of command line arguments with quotes into eval?
  • HttpException: Solr HTTP error: HTTP request failed, Failed to connect to 127.0.0.1 port 8983: Conne
  • how to validate a date in python
  • QObject::connect: Cannot connect (null)::mySignal() to (null)::mySlot()
  • how to save settings of eclipse?
  • How to call a CUDA file from a C++ header file?
  • Should be localization part of domain in DDD
  • How to find unmatched rows in oracle without using set operator and join & also Query the unmatc
  • Dynamically create controls in android using Kotlin
  • Simulate onFling() programmatically instead of detecting it (Android)
  • In Moment.js, how do you get the date of the next occurrence of a specific month (ex: 'next Jan
  • can you use embedded ruby in custom javascript files in rails?
  • Android studio import problems. (Apktool)
  • About global variables in Node.js
  • Use AutoIt with java applications
  • How to select multiple items from a List view - JavaFX 8
  • Comma decimal separator is ignored by ASP.NET MVC model binder