user833178
user833178

Reputation: 21

Change font size of gridview items (Android)

Below is code of my girdview. i need to change font size of the data. i aslo need to change default selection colour which is orange. please help i am new to android development.

       String[] tes={"AAA","BBB","CCC"};

       ArrayAdapter<String> aa = new ArrayAdapter<String>(
                this,
                android.R.layout.simple_list_item_1, 
                tes );
        gv.setAdapter(aa);
        gv.setOnItemClickListener(this);

Upvotes: 1

Views: 8676

Answers (4)

Edgardo Alvarez
Edgardo Alvarez

Reputation: 63

a little bit too late but for others who are looking for it will work :

first you create this a simple_textview.xml(put it a name)

<?xml version="1.0" encoding="utf-8"?>
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="10dp"
android:shadowColor="@color/grisActionBar"
/>

then in yout activity or fragment you set the adapter with the created textview.xml

gvMain = (GridView)v.findViewById(R.id.gridView);
gvMain.setAdapter(new ArrayAdapter<String
(getActivity(),R.layout.simple_textview,data));

Upvotes: 0

Bjorn
Bjorn

Reputation: 733

You have to change the font size in the baseadapter class for the gridview.

Like this:

public View getView(int position, View convertView, ViewGroup parent) {
      TextView tv;
if (convertView == null) {
    tv = new TextView(context);
    tv.setLayoutParams(new GridView.LayoutParams(100, 80));
    tv.setTextSize(20);   //text size in gridview
}

The gridview just show whatever the

gridview.setAdapter(new MyAdapter (thi));" //MyAdapter class is where the getView method run

sets the setAdapter to contain.

Upvotes: 3

Zwiebel
Zwiebel

Reputation: 1615

You can change it in the XML file, if you write android:textColor="#000000" where 000000 is the code of your color hexcode what you want.

Upvotes: 0

Egor
Egor

Reputation: 40203

You can try to achieve this by changing styles of your widgets. Take a look a this post to learn to apply styles and themes. Also you'll find description of all android styles and themes there. Hope this helps.

Upvotes: 0

Related Questions