Reputation: 2910
Is it possible to override the standard layouts that are provided with Android? Is it for example possible to make the text smaller for android.R.layout.simple_list_item_checked? Or would I simply need to make my own layout to do this? Thanks.
Upvotes: 3
Views: 1319
Reputation: 2804
Yes, it is. Here's a similar thing being accomplished (res/values/styles.xml):
<?xml version="1.0" encoding="utf-8"?>
<resources>
<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>
<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>
</style>
</resources>
And then, when you want to apply the style to an element in the layout file that you have created (main.xml, res/layout/your_custom_layout.xml):
<?xml version="1.0" encoding="utf-8"?>
<TableRow
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/questionTableRow"
style="@style/questionTableRow"
Obviously you are looking to accomplish this with a textView. I provided an example of my own code where the textView gets a specific style. I actually don't even have that textView style applied, but I pasted in where I applied a style to a tableRow, just so you see how to apply it to an xml element.
Does this do what you need?
Upvotes: 0
Reputation: 3804
You have to make your own layout. In order to make a custom layout and use a standard adapter (like ArrayAdapter) you have to specifiy the same id(s) in your custom layout as in the standard layouts. For example the TextView in simple_list_item_checked has the id "@android:id/text1" (http://www.devdaily.com/java/jwarehouse/android-examples/platforms/android-2/data/res/layout/simple_list_item_checked.xml.shtml). In your custom layout you specify that id. Thus you do not have to write a custom adapter. So the best way is just by copying the standard xml layout and change what you wanne change
Upvotes: 1