Reputation: 21
My Android Application has a series of fragment which are the same in some style , for example,title. I can run my app without style like this.
<TextView
android:layout_width="match_parent"
android:layout_height="60dp"
android:background="#4880ff"
android:textStyle="bold"
android:textSize="24sp"
android:textColor="#fff"
android:gravity="center_vertical"
android:text="STEP3\n最后,确定闹钟在哪些日子响起"/>
but when I try to use a style like this enter image description here and the style tag like this. enter image description here
Suddenly an ERROR occured.
Upvotes: 2
Views: 79
Reputation: 11
You can do like this.
<TextView
style="@style/CodeFont"
android:text="@string/hello" />
Add style like below code
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="CodeFont" parent="@android:style/TextAppearance.Medium">
<item name="android:layout_width">fill_parent</item>
<item name="android:layout_height">wrap_content</item>
<item name="android:textColor">#00FF00</item>
<item name="android:typeface">monospace</item>
</style>
</resources>
You can define text color, background, style etc.
Upvotes: 0
Reputation: 1517
do not have to do any special thing simply add this code
android:contentDescription="@string/desc"
<TextView
android:layout_width="match_parent"
android:layout_height="60dp"
android:background="#4880ff"
android:textStyle="bold"
android:textSize="24sp"
android:textColor="#fff"
android:gravity="center_vertical"
android:text="STEP3\n最后,确定闹钟在哪些日子响起"
android:contentDescription="@string/desc" />
in your textview and make a string file in string xml name desc and write any thing in it. it will work..
Upvotes: 0
Reputation: 75788
At first must use
android:layout_height
instead of android:height
set android:textColor="#ffffff"
for better approach .
Finally Your add_title
looks like
android:layout_height="60dp"
Upvotes: 1
Reputation: 23269
Make sure your view has an android:layout_height
attribute defined, either within the view or the style.
It seems to be missing from your style and if you remove it from the view the system will complain.
android:height
is not the same as android:layout_height
, change your style to have android:layout_height
Upvotes: 1