Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

1. What button properties are similar to the properties for a label? 2. Explain

ID: 3812189 • Letter: 1

Question

1. What button properties are similar to the properties for a label? 2. Explain how to set borderwidth, borderColor, and borderRadius properties of the Button Object for an Android phone application. 3. How is the background color of a button set? 4. How would you center a button on a screen? 5. What is an event handler? When is is 'fired off' for a button? 6. How can multiple buttons use the same event handler? 7. How can you disable a button? 8., what is a way that data can be saved after a program is terminated and then restarted again? 9. Explain each element of the application life cycle, including what modules are executed during each cycle.

Explanation / Answer

Solutions:

1.

Labels:

The Label is the smallest control which is used to display some text on the screen.

Button:

Button is a control that performs an action , when tapped or pressed.

Label and Button properties which are similar:

2.

To set Borderwidth property using xml

We can choose any of the following mentioned way to set the border width of a button.

Note:

dp: Density Independent Pixel, it varies based on screen destiny.


borderColor :

There is no concept of borders as an attribute for Button in Android Studio. But you can use a separate drawable.

The same is true for border radius.

We can set the border color and the bordor radius of a Button as follows:

<Button

android:background=“@drawable/yourfile”/>

<selector xmlns:android=“http://schemas.android.com/apk/res/android”>

   <item>

       <shape android:shape=“rectangle”>

           <stroke android:color=“#8A2BE2”    android:width=“2dp” />

           <corners android:radius=“15dp” />

       </shape>

   </item>

</selector>

3. Use the following property

<Button

android:background=“#ff2fa0ff” />

4. Use the following prperty

<Button

android:layout_centerHorizontal=“true” />