Graphics Programs Reference
In-Depth Information
After warnings have been removed, replace the entire (XML) UI layout in your pro-
ject's res/layout/main.xml with the contents of Listing 1-1 . Notice the main
difference between Listing 1-1 and the default UI layout (of the blank Activity
template) is the root tag RelativeLayout .
Listing 1-1. GLES VERSION/res/layout/main.xml
<LinearLayout
xmlns:android=" http://schemas.android.com/apk/res/
android "
xmlns:tools=" http://schemas.android.com/tools "
android:layout_width="match_parent"
android:layout_height="match_parent" >
<TextView
android:id="@+id/textview1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:padding="@dimen/padding_medium"
android:text="@string/hello_world"
tools:context=".Main" />
</LinearLayout>
Listing 1-1 places a TextView on the screen. This TextView is as wide as the
screen in any orientation and has an id of “textview1.” Additionally, its padding-di-
mensions and text are defined in the dimens.xml and strings.xml files, re-
spectively, inside this project's res/values folder.
Now, replace the onCreate method of the blank Activity (Main.java)
with the onCreate method from Listing 1-2 .
Listing 1-2. GLES VERSION/src/com/apress/android/glesversion/Main.java
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
 
 
 
 
Search WWH ::




Custom Search