Skip to content

Instantly share code, notes, and snippets.

Created April 25, 2015 02:23
Show Gist options
  • Save anonymous/256752a04db14a3947a8 to your computer and use it in GitHub Desktop.
Save anonymous/256752a04db14a3947a8 to your computer and use it in GitHub Desktop.
3 options for the layout of an activity for a quiz question
<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"
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"
tools:context=".MainActivity">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="16dp"
android:text="Quantity"
android:textAllCaps="true" />
<LinearLayout
android:layout_width="wrap_content"
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:layout_marginLeft="8dp"
android:layout_marginRight="8dp"
android:text="2"
android:textColor="@android:color/black"
android:textSize="16sp" />
<Button
android:layout_width="48dp"
android:layout_height="48dp"
android:onClick="increment"
android:text="+" />
</LinearLayout>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:text="Price"
android:textAllCaps="true" />
<TextView
android:id="@+id/price_text_view"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:text="$10"
android:textColor="@android:color/black"
android:textSize="16sp" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:onClick="submitOrder"
android:text="Order" />
</LinearLayout>
<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"
android:orientation="horizontal"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context=".MainActivity">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="16dp"
android:text="Quantity"
android:textAllCaps="true" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical">
<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:layout_marginLeft="8dp"
android:layout_marginRight="8dp"
android:text="2"
android:textColor="@android:color/black"
android:textSize="16sp" />
<Button
android:layout_width="48dp"
android:layout_height="48dp"
android:onClick="increment"
android:text="+" />
</LinearLayout>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:text="Price"
android:textAllCaps="true" />
<TextView
android:id="@+id/price_text_view"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:text="$10"
android:textColor="@android:color/black"
android:textSize="16sp" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:onClick="submitOrder"
android:text="Order" />
</LinearLayout>
<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"
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"
tools:context=".MainActivity">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="16dp"
android:text="Quantity"
android:textAllCaps="true" />
<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:layout_marginLeft="8dp"
android:layout_marginRight="8dp"
android:text="2"
android:textColor="@android:color/black"
android:textSize="16sp" />
<Button
android:layout_width="48dp"
android:layout_height="48dp"
android:onClick="increment"
android:text="+" />
</LinearLayout>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:text="Price"
android:textAllCaps="true" />
<TextView
android:id="@+id/price_text_view"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:text="$10"
android:textColor="@android:color/black"
android:textSize="16sp" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:onClick="submitOrder"
android:text="Order" />
</LinearLayout>
@dalila07
Copy link

optionA

@Islam3li
Copy link

nice option A is correct

@SultonN
Copy link

SultonN commented Jul 12, 2020

A is correct

@SultonN
Copy link

SultonN commented Jul 12, 2020

correct A option
A

@AdmiralAssassin
Copy link

A

@AMINELid
Copy link

answear is A
android:orientation="horizontal"

@bash-tag
Copy link

A is the correct answer.

@prateek-code-22
Copy link

option A

@ntenko07
Copy link

ntenko07 commented Oct 8, 2020

Positions_views
A is the correct answer.

@AlanTso
Copy link

AlanTso commented Nov 20, 2020

Hi, I don't know why the button is not a square even I try width = 48dp and height =48dp.
Question_not square
Can anyone tell me the reason and how to fix? Many thanks

@sonukiwi
Copy link

sonukiwi commented Dec 4, 2020

Definitely option A is correct.

@januniku812
Copy link

A

@hrajvanshi977
Copy link

A

@Elbek96
Copy link

Elbek96 commented Jan 18, 2021

Безымянный

@dalila07
Copy link

dalila07 commented Jan 18, 2021 via email

@pro-coder-fast
Copy link

A

@JamalAlsanabani
Copy link

JamalAlsanabani commented Mar 17, 2021

A

@Abhishek-Kumar-Sah
Copy link

A

@VivOO7
Copy link

VivOO7 commented Apr 23, 2021

A

@iamsamuelhere
Copy link

A

@kalsmic
Copy link

kalsmic commented May 4, 2021

A

@xJessyx
Copy link

xJessyx commented May 27, 2021

A

@sakibguy
Copy link

a

@ghanwaar
Copy link

A exact but logically all
task3

@ghanwaar
Copy link

Task 4 : Choosing the Right XML Layou
task4
t

@akftes
Copy link

akftes commented Mar 27, 2022

option A is correct Answer Because orientation property of root view is vertical But in Option B That's Horizontal....:)

@Harriskobia
Copy link

Option A is correct

@AbdusamidDev
Copy link

OPTION A is the Correct Answer because OPTION B is created by horizontal orientation and OPTION C is different with the layouts in activity_main.xml

Copy link

ghost commented Dec 4, 2022

OPTION -A

@kodirr
Copy link

kodirr commented Apr 30, 2023

A

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment