Hiện tại, bạn không thể đặt kiểu của Chế độ xem theo chương trình.
Để làm được việc này bạn có thể tạo một tập tin xml mẫu bố trí với phong cách giao, ví dụ như trong res/layout
tạo tvtemplate.xml
như với các nội dung sau đây:
<?xml version="1.0" encoding="utf-8"?>
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="This is a template"
style="@android:style/TextAppearance.DeviceDefault.Small" />
sau đó thổi phồng này để nhanh chóng TextView mới của bạn:
TextView myText = (TextView)getLayoutInflater().inflate(R.layout.tvtemplate, null);
Nguồn
2013-02-22 08:53:40
bạn không thể đặt kiểu của bất kỳ chế độ xem nào theo thực tế. nhưng bạn có thể đặt các thuộc tính riêng lẻ của chế độ xem –
Bản sao có thể có của [Android - đặt TextView TextStyle theo lập trình?] (http://stackoverflow.com/questions/7919173/android-set-textview-textstyle-programmatically) –