- <TextView
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_centerHorizontal="true"
- android:layout_centerVertical="true"
- android:text="@string/hello_world"
- tools:context=".MainActivity" />
一直對於 tools:context=".MainActivity"這句不懂,今天查了下,發現是這樣的:
tools:context="activity name"這一句不會被打包進APK。只是ADT的Layout Editor在你當前的Layout文件裏面設置對應的渲染上下文,說明你當前的Layout所在的渲染上下文是activity name對應的那個activity,如果這個activity在manifest文件中設置了Theme,那麼ADT的Layout Editor會根據這個Theme來渲染你當前的Layout。就是說如果你設置的MainActivity設置了一個Theme.Light(其他的也可以),那麼你在可視化佈局管理器裏面看到的背景阿控件阿什麼的就應該是Theme.Light的樣子。僅用於給你看所見即所得的效果而已。