簡體   English   中英

在Android ListView中,如何根據android設備的字體大小設置動態更改行高

[英]In Android ListView, how to change the row height dynamically according to the setting of font-size of android devices

在Android ListView中,我想根據android設備的字體大小設置動態更改每行的高度。

我正在嘗試在我的主要活動的“ onWindowFocusChanged”方法中實現它,如下所示。

但是,我不知道如何更改每行的高度。

@Override
public void onWindowFocusChanged(final boolean hasFocus) {
    super.onWindowFocusChanged(hasFocus);
    listView = (ListView) findViewById(android.R.id.list);

    for (int i = 0; i < adapter.getCount(); i++) {
            View listItem = adapter.getView(i, null, listView);
            // the process of change height of each row.
        }

    }

} 

你能告訴我如何實現嗎?

在行XML文件中的inf_row xml imean中,您必須將高度設置為換行內容。

             <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content" 
                android:text=""
                android:textAppearance="?android:attr/textAppearanceMedium"  />

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM