Relative layout RelativeLayout Android example
xml RelativeLayout Android example:
Eclipse graphical xml layout editor
[caption id="attachment_896" align="alignleft" width="261" caption="Relativelayout Eclipse graphical editor"][/caption]
res/layout/main.xml
Eclipse graphical xml layout editor
[caption id="attachment_896" align="alignleft" width="261" caption="Relativelayout Eclipse graphical editor"][/caption]
res/layout/main.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="//schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<TextView
android:id="@+id/idLabel"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Enter word"/>
<EditText
android:id="@+id/idEntry"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="@android:drawable/editbox_background"
android:layout_below="@id/idLabel"/>
<Button
android:id="@+id/idOk"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/idEntry"
android:layout_alignParentRight="true"
android:layout_marginLeft="10dip"
android:text="OK" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toLeftOf="@id/idOk"
android:layout_alignTop="@id/idOk"
android:text="Cancel" />
</RelativeLayout>
396LW NO topic_id
AD
Další témata ....(Topics)
How to quickly change all icon set in .apk project with Eclipse:
Right click on project in folder tree
Select New - Ohter
In open wizard dialog select Android Icon Set
Set Icon set name:
Open some large icon for your project for example 512x512 px and wizard will make all set of icons from one largest icon:
Wizard will create all set of icons from this one largest icon.
Click on finish button:
Right click on project in folder tree
Select New - Ohter
In open wizard dialog select Android Icon Set
Set Icon set name:
Open some large icon for your project for example 512x512 px and wizard will make all set of icons from one largest icon:
Wizard will create all set of icons from this one largest icon.
Click on finish button:
GregorianCalendar cal = new GregorianCalendar(); Boolean b = cal.isLeapYear(2012); // true, Android example.
public class MainActivity extends Activity {
TextView txtV;
Context cntx;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
txtV = (TextView)findViewById(R.id.idLabel);
cntx = this;
StringBuilder strBuild = new StringBuilder();
GregorianCalendar cal = new GregorianCalendar();
Boolean b = cal.isLeapYear(2012); // true
strBuild.append("Is leap year 2012? " + b + "
");
b = cal.isLeapYear(2014); // false
strBuild.append("Is leap year 2014? " + b + "
");
txtV.setText(strBuild);
}
}
In html is horizontal line a tag br. In Android source code you can use a View as xml example bellow.
<View
android:layout_width="fill_parent"
android:layout_height="4dip"
android:background="#ffffff"
android:paddingBottom="10dip"
/>
drawText(), setColor(), setTextSize(), setTextAlign()
public class ApokusActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(new SampleView(this));
}
private static class SampleView extends View {
// CONSTRUCTOR
public SampleView(Context context) {
super(context);
setFocusable(true);
}
@Override
protected void onDraw(Canvas canvas) {
Paint paint = new Paint();
paint.setColor(Color.YELLOW);
paint.setTextSize(60);
//paint.setTextAlign(Paint.Align.CENTER);
canvas.drawText("Hello world!", 0, 50, paint);
}
}
}
Canvas, drawLine(), setStrokeWidth(), Paint, setAntiAlias(boolean), onDraw()
public class MainActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(new SampleView(this));
}
private static class SampleView extends View {
// CONSTRUCTOR
public SampleView(Context context) {
super(context);
setFocusable(true);
}
@Override
protected void onDraw(Canvas canvas) {
canvas.drawColor(Color.YELLOW);
Paint p = new Paint();
// smooths
p.setAntiAlias(true);
p.setColor(Color.RED);
p.setStrokeWidth(4.5f);
// opacity
p.setAlpha(0x80); //
// drawLine (float startX, float startY, float stopX, float stopY,
// Paint paint)
canvas.drawLine(0, 0, 40, 40, p);
canvas.drawLine(40, 0, 0, 40, p);
}
}
}
Editace: 2011-09-28 08:15:02
Počet článků v kategorii: 396
Url:relative-layout-relativelayout-android-example