Changing the style of standard android.R.layout options?

Is it possible to override the default layouts that ship with Android? Is it possible, for example, to make the text smaller for android.R.layout.simple_list_item_checked? Or do I just need to make my own layout for this? Thank you.


source to share

2 answers

You need to create your own layout. To create your own layout and use a standard adapter (such as ArrayAdapter), you must specify the same ID in your custom layout as you would in standard layouts. For example, the TextView in simple_list_item_checked has the id "@android: id / text1" ( shtml). In your custom layout, you specify this ID. This way you don't need to write a custom adapter. So the best way is to just copy the standard xml layout and change what you wanne change



Yes it is. A similar thing is done here (res / values ​​/ styles.xml):

<?xml version="1.0" encoding="utf-8"?>
<style name="ContactLabelTextView">
    <item name="android:layout_width">wrap_content</item>
    <item name="android:layout_height">wrap_content</item>
    <item name="android:gravity">right</item>
    <item name="android:textSize">14sp</item>
    <item name="android:textColor">@android:color/white</item>
    <item name="android:layout_marginLeft">5dp</item>
    <item name="android:layout_marginRight">5dp</item>
    <item name="android:layout_marginTop">5dp</item>
  <style name="questionTableRow">
      <item name="android:layout_width">wrap_content</item>
      <item name="android:layout_height">wrap_content</item>
      <item name="android:layout_margin">5dp</item>
      <item name="android:layout_marginLeft">5dp</item>
      <item name="android:background">@drawable/textview_border</item>


And then when you want to style an element in the layout file you created (main.xml, res / layout / your_custom_layout.xml):

<?xml version="1.0" encoding="utf-8"?>


Obviously, you want to accomplish this with a textView. I have provided an example of my own code where the textView gets a certain styling. I don't even have a textView style like this, but I pasted where I applied the style to the tableRow so you can see how to apply it to the xml element.

Does this do what you want it to?



All Articles