Last active
December 22, 2020 12:48
-
-
Save udacityandroid/d84866a8d84d53e9d3f6 to your computer and use it in GitHub Desktop.
Android for Beginners : Header Text Style Solution
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<ScrollView 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" | |
tools:context=".MainActivity"> | |
<LinearLayout | |
android:layout_width="match_parent" | |
android:layout_height="match_parent" | |
android:orientation="vertical" | |
android:paddingBottom="@dimen/activity_vertical_margin" | |
android:paddingLeft="@dimen/activity_horizontal_margin" | |
android:paddingRight="@dimen/activity_horizontal_margin" | |
android:paddingTop="@dimen/activity_vertical_margin"> | |
<EditText | |
android:id="@+id/name_field" | |
android:layout_width="match_parent" | |
android:layout_height="wrap_content" | |
android:hint="@string/name" | |
android:inputType="text" /> | |
<TextView | |
style="@style/HeaderTextStyle" | |
android:text="@string/toppings" /> | |
<CheckBox | |
android:id="@+id/whipped_cream_checkbox" | |
android:layout_width="wrap_content" | |
android:layout_height="wrap_content" | |
android:paddingLeft="24dp" | |
android:text="@string/whipped_cream" | |
android:textSize="16sp" /> | |
<CheckBox | |
android:id="@+id/chocolate_checkbox" | |
android:layout_width="wrap_content" | |
android:layout_height="wrap_content" | |
android:paddingLeft="24dp" | |
android:text="@string/chocolate" | |
android:textSize="16sp" /> | |
<TextView | |
style="@style/HeaderTextStyle" | |
android:text="@string/quantity" /> | |
<LinearLayout | |
android:layout_width="match_parent" | |
android:layout_height="wrap_content" | |
android:orientation="horizontal"> | |
<Button | |
android:layout_width="48dp" | |
android:layout_height="48dp" | |
android:onClick="decrement" | |
android:text="-" /> | |
<TextView | |
android:id="@+id/quantity_text_view" | |
android:layout_width="wrap_content" | |
android:layout_height="wrap_content" | |
android:paddingLeft="8dp" | |
android:paddingRight="8dp" | |
android:text="@string/initial_quantity_value" | |
android:textColor="@android:color/black" | |
android:textSize="16sp" /> | |
<Button | |
android:layout_width="48dp" | |
android:layout_height="48dp" | |
android:onClick="increment" | |
android:text="+" /> | |
</LinearLayout> | |
<Button | |
android:layout_width="wrap_content" | |
android:layout_height="wrap_content" | |
android:layout_marginTop="16dp" | |
android:onClick="submitOrder" | |
android:text="@string/order" /> | |
</LinearLayout> | |
</ScrollView> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<resources> | |
<!-- Base application theme. --> | |
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar"> | |
<!-- Customize your theme here. --> | |
</style> | |
<!-- Style for header text in the order form --> | |
<style name="HeaderTextStyle"> | |
<item name="android:layout_width">wrap_content</item> | |
<item name="android:layout_height">48dp</item> | |
<item name="android:gravity">center_vertical</item> | |
<item name="android:textAllCaps">true</item> | |
<item name="android:textSize">15sp</item> | |
</style> | |
</resources> |
what is the difference between styles and going through the android: function?
what is the difference between styles and going through the android: function?
It's about whether you'll use again or not, if you use that ever again you may want to add that style to styles.xml file. 👍
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@sap2ps, I think we have to modify styles.xml.