如何在此处添加文本大小代码以减小默认大小。提前致谢。

package com.xxx;

public class Score extends AppCompatActivity {
    ListView lstView;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_score_main);

        mainView = (ListView)findViewById(R.id.mainRanking);
        DbHelper db = new DbHelper(this);
        List<Ranking> mainRanking = db.getRanking();
        if(mainRanking.size() > 0)
        {
            CustomAdapter adapter = new CustomAdapter(this,mainRanking);
            lstView.setAdapter(adapter);
        }
    }
}

最佳答案

将此添加到您的styles.xml

<style name="ListViewTheme">
    <item name="android:textSize">12sp</item>
</style>


然后将其添加到您的ListView标记中:

<ListView
    android:id="@+id/mainRanking"
    android:theme="@style/ListViewTheme"
    .../>

10-07 19:48