Anas
Anas

Reputation: 713

Android Studio Projects Templates

i'm new to Android Programming and now following official android training here

i'm actually confused since courses are different from what i get in Android Studio 1.4.1, and i have some questions :

thank you

Upvotes: 3

Views: 3179

Answers (1)

hata
hata

Reputation: 12478

There is a Template called "Empty Activity" in "Create New Project" dialog. It seems to be equivalent to the former "Blank Activity".

Create New Project dialog

And it has a single layout.xml.

Note that it is not explicitly equivalent to the former "Blank Activity" because it is gotten rid of any Menus. However, I think it is suitable for your tutorial purpose for its simplicity.

Besides Floating Button, the current "Blank Activity" has an ActionBar (implemented with Toolbar) and nested layout (using inclusion). It may look quite complex for newbies.


How can I get the actual layout ... ?

You can get the "Blank Activity" template's actual layout by including content_main.xml into activity_main.xml. The structure is below:

<android.support.design.widget.CoordinatorLayout>

    <android.support.design.widget.AppBarLayout>
        <android.support.v7.widget.Toolbar />
    </android.support.design.widget.AppBarLayout>

    <RelativeLayout>
        <TextView />
    </RelativeLayout>

    <android.support.design.widget.FloatingActionButton />

</android.support.design.widget.CoordinatorLayout>

In which I can add some TextViews?

It is the RalativeLayout shown above. Set an id to the RelativeLayout and find it.

In content_main.xml (set id):

<RelativeLayout
    android:id="@+id/content_viewgroup"
    ...
    >

In onCreate (find it):

RelativeLayout relativeLayout = (RelativeLayout) findViewById(R.id.content_viewgroup);

And add your textView to the relativeLayout instead of setting it as the contentView.

relativeLayout.addView(textView); // instead of setContentView(textView);

Upvotes: 3

Related Questions