.


:




:

































 

 

 

 


Android-. Design Text




. , ( ).

Project : app Gradle Scripts. app - , .. , .

app : manifests, java res. .

manifest. manifest AndroidManifest.xml. Gradle. - , , - . , 2- , 1- , . - , . AndroidManifest.xml Android-.

java. - . . MainActivity.

res. res , : drawable, layout, menu, values. .

- drawable , , .. , ..

- layout xml- , ( , , ..). activity_main.xml, .

- menu - xml-, . main.xml, menu.

- value - , : , , , , .

, . , .1.11. (Palette) (.1.12).

 

.1.11. .1.12. Palette

Palette , , , , . Design Text.

Design . .

Text . , . , .

 

 

AndroidManifest.xml

. (.1.13):

.1.13. AndroidManifest.xml

XML, .

<manifest>. :

xmlns:android Android,

package .

:

android:versionCode .

android:versionName .

<manifest> <application>. . (<activity>, <service>, <receiver>, <provider> ), . , , . . , , . Android:

android:allowBackup - ,

android:icon ,

android:label .

<application> <activity>, (), .

activity_main.xml

activity_main.xml . - Design Text. Text - . (.1.14):

.1.14. activity_main.xml

XML, .

<RelativeLayout>. :

xmlns:android Android,

xmlns:tools - ,

android:layout_width=match_parent - (match_parent - ),

android:layout_ height =match_parent - ,

android:paddingLeft =16dp ,

android:paddingRight =16dp ,

android:paddingTop =16dp ,

android:paddingBottom =16dp ,

android:paddingLeft =16dp ,

 

MainActivity.java

, Java, .

:

package com.example.misis.myapplication;

 

import android.support.v7.app.ActionBarActivity;

import android.os.Bundle;

import android.view.Menu;

import android.view.MenuItem;

 

public class MainActivity extends ActionBarActivity {

 

@Override

protected void onCreate(Bundle savedInstanceState) {

super.onCreate(savedInstanceState);

setContentView(R.layout.activity_main);

}

 

@Override

public boolean onCreateOptionsMenu(Menu menu) {

//Inflate the menu; this adds items to the action bar if it is present.

getMenuInflater().inflate(R.menu.menu_main, menu);

return true;

}

 

@Override

public boolean onOptionsItemSelected(MenuItem item) {

// Handle action bar item clicks here. The action bar will

// automatically handle clicks on the Home/Up button, so long

// as you specify a parent activity in AndroidManifest.xml.

int id = item.getItemId();

 

//noinspection SimplifiableIfStatement

if (id == R.id.action_settings) {

return true;

}

 

return super.onOptionsItemSelected(item);

}

}

. .

public class MainActivity.

 

, . , Hellow World! , , TextView "Hellow World!" ( "Hellow World!" ) , Text , , ( , ):

< TextView

android:text="@string/hello_world"

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:layout_alignParentTop="true"

android:layout_centerHorizontal="true"

android:layout_marginTop="183dp"

 

android:textSize="25pt"/>

 

Preview .

! APK , , . , ( , ) Run, Run --- Run "app", Shift + F10. / . , Android !

 

. activity_main.xml. - Design Text.

Text.

<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"

android:paddingLeft="@dimen/activity_horizontal_margin"

android:paddingRight="@dimen/activity_horizontal_margin"

android:paddingTop="@dimen/activity_vertical_margin"

android:paddingBottom="@dimen/activity_vertical_margin"

tools:context=".MainActivity">

 

<TextView

android:text="@string/hello_world"

android:layout_width="wrap_content"

android:layout_height="wrap_content" />

 

</RelativeLayout>

, android:text="@string/hello_world" android:text="Hello World!". , Hello World!, . , , , . , , , 16dp. .. , , @string/hello_world. Ctrl + - () .

XML-. RelativeLayout, TextView, . , hello_world. res/values/strings.xml.

Java- (MainActivity.java)

 

package ru.alexanderklimov.helloworld;

 

import android.app.Activity;

import android.os.Bundle;

import android.view.Menu;

import android.view.MenuItem;

 

public class MainActivity extends Activity {

 

@Override

protected void onCreate(Bundle savedInstanceState) {

super.onCreate(savedInstanceState);

setContentView(R.layout.activity_main);

}

 

@Override

public boolean onCreateOptionsMenu(Menu menu) {

 

// Inflate the menu; this adds items to the action bar if it is present.

getMenuInflater().inflate(R.menu.main, menu);

return true;

}

 

@Override

public boolean onOptionsItemSelected(MenuItem item) {

// Handle action bar item clicks here. The action bar will

// automatically handle clicks on the Home/Up button, so long

// as you specify a parent activity in AndroidManifest.xml.

int id = item.getItemId();

if (id == R.id.action_settings) {

return true;

}

return super.onOptionsItemSelected(item);

}

}

, MainActivity java ( Java). - (Package Name). . . . , ( Unused import statement) .

, (extends) Activity. . , ActionBarActivity, . , Android 4.1. , Android 4, , Android . ActionBarActivity . Activity. , . . , .

onCreate() , . .

super.onCreate(savedInstanceState); , . , .

setContentView(R.layout.activity_main); . setContentView(int) . res/layout. activity_main.xml. cat.xml . :

 

setContentView(R.layout.cat);

, . . , Settings.





:


: 2016-11-24; !; : 826 |


:

:

: , .
==> ...

1348 - | 1292 -


© 2015-2024 lektsii.org - -

: 0.048 .