To style a text view in code in a constructor
TextView myText = new TextView(MyActivity.this, null, R.style.my_style );
I tried it like this, but the style didn't apply at all. so
myText.setTextAppearance(MyActivity.this, R.style.my_style)
I tried this method, but it didn't work. What should I do?
<?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="@style/my_style" />
I'm not sure if you specify a style on the code, but you can make a template layout by bypassing it
After defining it as above,
in the text view
TextView myText = (TextView)getLayoutInflater().inflate(R.layout.tvtemplate, null);
There's a way to define it this way.
© 2024 OneMinuteCode. All rights reserved.