2
我知道有很多關於setTextAppearance的討論,但我搜索,餘did't發現任何爲我工作...
我編程設置代碼爲一個textView,這是在一個表中。
但是,當我試圖從stylesView中調用styles.xml中的樣式時,它不適用。
從styles.xml:setTextAppearance()不工作textviews
<style name="ElemTabArtikl">
<item name="android:layout_marginLeft">10dp</item>
<item name="android:textAppearance">?android:attr/textAppearanceMedium</item>
</style>
在Java代碼:
TextView tvNazArt = new TextView(this);
tvNazArt.setLayoutParams(new TableRow.LayoutParams(TableRow.LayoutParams.WRAP_CONTENT, TableRow.LayoutParams.WRAP_CONTENT, 0.4f));
tvNazArt.setTextAppearance(this, R.style.ElemTabArtikl);
tvNazArt.setText(NazivArt);
tvNazArt.setPadding(10, 0, 0, 0);
artikliVrstica.addView(tvNazArt);
'android.R.style.textAppearanceMedium'應該是'android.R.style.TextAppearance_Medium'。 –
謝謝,更新 – dberm22