The default font of the ListView in Android can sometimes not meet the needs of the design, need to design their own style,
The general online introduction is to create a new one of their own ListView adapter Myadapter, there is another way to avoid the trouble of new Myadapter.
1, the new Array_adapter.xml under the res/layout/:
1 <?XML version= "1.0" encoding= "Utf-8"?>2 <TextViewxmlns:android= "Http://schemas.android.com/apk/res/android"3 Android:id= "@+id/textview"4 Android:layout_width= "Wrap_content"5 Android:layout_height= "Wrap_content"6 android:textsize= "24SP"7 android:padding= "10DP" 8 Android:textcolor= "#ff000000" 9 ANDROID:SHADOWDX= "4"Ten Android:shadowdy= "4" One Android:shadowradius= "2" A />
"Android:textsize" and "Android:textcolor" can specify the font size and color, of course, you can also make other settings such as adding a Shadow "Android:shadowcolor".
2. Create the adapter in Mainactivity and associate the Array_adapter.xml with the adapter:
1 PrivateListView m_loglist=NULL;2 PrivateArrayadapter adapter =NULL;3 PrivateArraylist<string>m_logtexts;4 5 Public voidonCreate (Bundle savedinstancestate) {6 Super. OnCreate (savedinstancestate);7 // .. .. ..8 9M_loglist = (ListView) This. Findviewbyid (r.id.listview1);Tenm_logtexts=NewArraylist<string>(); OneM_logtexts.add ("Hello World.")); AM_logtexts.add ("11 22 33"); - - //create the adapter and give the data to the adapter theadapter =NewArrayadapter ( This, r.layout.array_adapter,m_logtexts); - //add an adapter to the ListView - M_loglist.setadapter (adapter); - + } - + Public voidOnLog (String str) { A at while(M_logtexts.size () >15) - { -M_logtexts.remove (0); - } - M_logtexts.add (str); - in //Notification Display - adapter.notifydatasetchanged (); to}
Effect
Modify Android ListView font size and color