Skip to content

Instantly share code, notes, and snippets.

@udacityandroid
Created May 28, 2015 01:36
Show Gist options
  • Star 57 You must be signed in to star a gist
  • Fork 67 You must be signed in to fork a gist
  • Save udacityandroid/7a9b5288975819fa2c25 to your computer and use it in GitHub Desktop.
Save udacityandroid/7a9b5288975819fa2c25 to your computer and use it in GitHub Desktop.
Android Development for Beginners : Happy Birthday Starting XML
<RelativeLayout 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">
<TextView android:text="Happy Birthday YOURFRIENDHERE" android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</RelativeLayout>
@LiliyaRiabova
Copy link

My variant
<RelativeLayout 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">

<ImageView
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:scaleType="centerCrop"
    android:id="@+id/ImageView"
    android:src="@drawable/learn"></ImageView>


<TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:textSize="36sp"
    android:frontFamily="sans-serif-light"
    android:textColor="@android:color/white"
    android:padding="20dp"
    android:text="Happy Birthday, ALEX!"
    android:textStyle="italic"/>


<TextView
    android:id="@+id/sender"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="From, LILY!"
    android:layout_alignParentBottom="true"
    android:layout_alignParentRight="true"
    android:textSize="36sp"
    android:frontFamily="sans-serif-light"
    android:textColor="@android:color/white"
    android:padding="20dp"
    android:textStyle="italic"
    />

@sslaia
Copy link

sslaia commented May 10, 2019

image
Please help, Image alignment is not coming correct.

If you haven't solved the problem yet, I just wanted to say that you need to change the LinearLayout to RelativeLayout. Thanks.

@Mahmoud-taifa
Copy link

<ImageView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:src="@drawable/androidparty" />

<TextView android:text="Happy Birthday mofta7!" android:layout_width="wrap_content"
    android:layout_height="wrap_content" />

<TextView android:text="from taifa" android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentRight="true"
    android:layout_alignParentBottom="true"/>

@Simulecrum
Copy link

Hi All

My TextView androidtext="from" will not move right, or to the bottom when I enter the lines of (layout_alignParentRight, or Bottom). I have even tried copying some of the examples here, but nothing seems to work. Android Studio keeps saying I should use (alignParentEnd) and once I do there is says I should also add (alignParentRight). ???
However I have adding to use the drag and drop functions within the program, which is a quick solution, but overall it seems I am missing something. Any idea?

<androidx.constraintlayout.widget.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">

<TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentRight="true"
        android:layout_alignParentBottom="true"
        android:text="From John"

@foobar167
Copy link

foobar167 commented Sep 20, 2019

Birthday Card

from FooBar167

<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".MainActivity">

    <ImageView
        android:id="@+id/party"
        android:src="@drawable/androidparty"
        android:contentDescription="@string/img_description"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:scaleType="centerCrop" />

    <TextView
        android:layout_width="match_parent"
        android:layout_height="@dimen/size_large"
        app:autoSizeTextType="uniform"
        android:lines="1"
        android:gravity="center"
        android:text="@string/happy_birthday_alex"
        android:textColor="@color/colorYellow"
        app:fontFamily="cursive"
        app:layout_constraintLeft_toLeftOf="parent"
        app:layout_constraintTop_toTopOf="parent"
        android:paddingTop="@dimen/vertical_margin"
        android:paddingBottom="@dimen/vertical_margin"
        android:paddingLeft="@dimen/horizontal_margin"
        android:paddingRight="@dimen/horizontal_margin" />

    <TextView
        android:layout_width="match_parent"
        android:layout_height="@dimen/size_small"
        app:autoSizeTextType="uniform"
        android:lines="1"
        android:gravity="end"
        android:text="@string/from_dzmitry"
        android:textColor="@color/colorYellow"
        app:fontFamily="cursive"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintRight_toRightOf="parent"
        android:paddingTop="@dimen/vertical_margin"
        android:paddingBottom="@dimen/vertical_margin"
        android:paddingLeft="@dimen/horizontal_margin"
        android:paddingRight="@dimen/horizontal_margin" />

</androidx.constraintlayout.widget.ConstraintLayout>

@ayman-mamdoh
Copy link

i have a constrain layout.
how can i make a relative layout instead?

@noura786
Copy link

noura786 commented Feb 2, 2020

how can I use me iPhone on the android studio or making the emulater

@singer0000
Copy link

<ImageView
    android:id="@+id/img_main"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:src="@drawable/hamada"
    android:scaleType="centerCrop"/>

<TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="Happy BirthDay ياحمادة يا صديق العمر "
    android:textSize="36sp"
    android:paddingLeft="10dp"
    android:paddingTop="10dp"
    android:layout_alignParentLeft="true"
    android:layout_alignTop="@+id/img_main"
    android:textColor="@android:color/white"
    android:fontFamily="sans-serif-condensed"
    />



<TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="من محمد"
    android:textSize="36sp"
    android:padding="10dp"
    android:fontFamily="serif"
    android:layout_alignParentBottom="true"
    android:layout_alignParentRight="true"

    android:textColor="@android:color/white"
    />

@ahmedawais
Copy link

<ImageView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:id = "@+id/androidparty"
    android:src="@drawable/androidparty" />


<TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="From Awais"
    android:textSize="40sp"
    android:textStyle="bold" />

<TextView
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_alignParentBottom="true"
    android:gravity="bottom"
    android:text="Happy birthday Ahmed"
    android:textStyle="bold"
    android:textSize="40sp" />

image

@MarcosPoloLinux
Copy link

<TextView
    android:id="@+id/happyBTV"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentTop="true"
    android:padding="20dp"
    android:text="Happy Birthday Rocio"
    android:textSize="30sp"
    android:textStyle="bold"
    android:textColor="@android:color/darker_gray"/>

<ImageView
    android:id="@+id/imagen"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_centerVertical="true"
    android:src="@drawable/androidparty" />

<TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentRight="true"
    android:layout_alignParentBottom="true"
    android:padding="20dp"
    android:text="From Marcos"
    android:textSize="25sp"
    android:textStyle="bold"
    android:textColor="@android:color/darker_gray"/>

@MarcosPoloLinux
Copy link

Screenshot_20200326_231950

@afarisamuel6
Copy link

<ImageView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:src="@drawable/androidparty"
    android:scaleType="centerCrop"
    />

<TextView android:text="Happy birthday Ben!"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:textSize="36sp"
    android:fontFamily="sans-serif-light"
    android:textColor="@android:color/white"
    android:padding="20dp"/>

<TextView android:text="From Sadat"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentBottom="true"
    android:layout_alignParentRight="true"
    android:textSize="36sp"
    android:fontFamily="sans-serif-light"
    android:textColor="@android:color/white"
    android:padding="20dp"/>
![Screen Shot 2020-05-23 at 5 50 36 AM](https://user-images.githubusercontent.com/64886805/82722810-72f89d00-9cb9-11ea-9aa5-d457ede2ff96.png)

@Paxlavonjon
Copy link

Menda cheklash tartibi mavjud.
qanday qilib uning o'rniga nisbiy tartibni qila olaman?

@tarikovish
Copy link

Screenshot (78)


<TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:fontFamily="@font/MAILRAYS"
    android:padding="20dp"
    android:text="Happy birthday tarik"
    android:textColor="@android:color/white"
    android:textSize="40sp" />

<TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentRight="true"
    android:layout_alignParentBottom="true"
    android:fontFamily="@font/ChopinScript"
    android:padding="30dp"
    android:text="From tarik"
    android:textColor="@android:color/white"
    android:textSize="36sp" />

@surajsahani
Copy link

https://www.udacity.com/api/nodes/4034888704/supplemental_media/androidpartyjpg/download

I wonder why I can't set other images rather than providing one.!

@adam4designSSS
Copy link

iSolve it
image

yyyyyyyyyyyyyys

@adam4designSSS
Copy link

@Eng1
Copy link

Eng1 commented Feb 25, 2021

How to correct this error? I [don't](url
2021-02-25
) find any ('') to correct or delete?

@Eng1
Copy link

Eng1 commented Feb 25, 2021

solved
android:scaleType="cenerCrop" for the image

@Eng1
Copy link

Eng1 commented Feb 25, 2021

2021-02-25 (2)

@Eng1
Copy link

Eng1 commented Feb 26, 2021

androidparty
2021-02-26 (1)
2021-02-26
What' wrong in this project ,how to correct?

@Eng1
Copy link

Eng1 commented Feb 26, 2021

2021-02-26 (2)

@surajsahani
Copy link

show me logcat

@interjeep
Copy link

Cool great thanks

@Eng1
Copy link

Eng1 commented Jun 1, 2021 via email

@mateendev3
Copy link

Thanks for the awesome course as a android beginner.

@hadeel-18
Copy link

image

@hadeel-18
Copy link

please help me
I don't have an android phone
How can i run the app??

@hadeel-18
Copy link

please help me
I don't have an android phone
How can i run the app??
image

@Mihir50
Copy link

Mihir50 commented Aug 14, 2021

@hadeel-18 use an emulator

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