8-Dynamic UI.pdf
Document Details
Uploaded by FreedFlute
Tags
Related
- Fundamentals of Android Applications (1).pdf
- Internship Training on Android App Development PDF
- Uchebn_posobie-Razrabotka-mobilnykh-prilozheniy-na-yazyke-JAVA-s-ispolzovaniem-ANDROID-STUDIO.pdf.pdf
- Lecture 6: Development For Mobile Development PDF
- LESSON-10-11_JAVA_EVENTLISTENER.pdf - Android Java File Structure
- Lecture 2_Android basics PDF
Full Transcript
Creating the Example Project in Android Studio Adding Views to an Activity The onCreate() method is currently designed to use a resource layout file for the user interface. Begin, therefore, by deleting this line from the method: The next modification...
Creating the Example Project in Android Studio Adding Views to an Activity The onCreate() method is currently designed to use a resource layout file for the user interface. Begin, therefore, by deleting this line from the method: The next modification to the onCreate() method is to write some Java code to add a RelativeLayout object with a single Button view child to the activity. Setting View Properties Set the background of the RelativeLayout view to be blue and the Button view to display text that reads “Press Me”. Adding Layout Parameters and Rules In order to instruct the layout view to place the button in a different location, in this case centered both horizontally and vertically, it will be necessary to create a LayoutParams object and initialize it with the appropriate values. The next step is to add some additional rules to the parameters to instruct the layout parent to center the button vertically and horizontally. Last step, need to pass the LayoutParams object through as an argument when the child view is added to the parent. or: Complete code Output