Android ү ққ View ә ViewGroup қ қ құ. View , ә ң қ UI , қ child-ң қ қ қ ө .
Android View, ViewGroup ә XML-ө ұ. қ, ққ , XML өң ққ құ [6,7].
, ң ққ қ қ . ұ ө қ ғ, , ә-ү ө ү ә-ү құ .
Android қ ү ғ қ ә қ ұ. ә , ғ, ә ә ө .
Қ құ қ қ Adobe Photoshop қ ө ғ ә қ res/darwble қ.
Қ ImageButton view- қғ. Ә ә қ ғғ. ImageButton қ қ ү қң ң қ , ғ Edit Background ң. Ә қ res/darawble қ . ә ң (10-).
11. View- қ ғ ә
Қ құ ә ә ө ғ XML құ:
1) ( 12). қ res ғ fragment_main.xml құ (res/layouts/fragment_main.xml). ұ activity- RelativeLayout ө қ. RelativeLayout- ә қ қ қ.
, қ, қң қ қғ ғ ImageButton view- қ. ә , ғ, ә ә ө . ә ү . ә ү қ ә ү ө. ұ ққ әң ққ ә ү қ.
|
|
ұ 1
Android қ ү ғ қ ә |
Ә ү Second_main.xml |
Paint.xml |
Ә Piano.xml |
Fragment_main.xml |
Ә ә қ ғ әң ә ә ұ . Ү ғ. ұ ү ғ қ қ . ө .
12. Қң
2) Ә ү. ұ second_main.xml құ. ұ қ ққ әң ққ ә ө . Ә ә ImageButton view- ұ. Adobe Photoshop қ ө ғ, res/drawble қ, ә ә, ә ImageButton ң қ ғ.
ImageButton view- RelativeLayout ққ, ә ң қ қ . :
<ImageButton
android:id="@+id/imageButton2"
android:layout_width="36dp"
android:layout_height="36dp"
android:layout_alignTop="@+id/imageButton1"
android:layout_toRightOf="@+id/imageButton1"
android:background="@drawable/a2"
android:src="@drawable/abc_ab_share_pack_holo_dark" />
ұ Ә ү ң ң ө. ң әқ ққ:
android:id@+id/imageButton2 ғ қ ү , ө ID.
android:layout_width=36dp, android:layout_height=36dp ң ұғ ғ ғ . ң ғ ә ң ұғ 36dp-ғ ң. Dp (Density-independent Pixels) ә ү ө ү ө ү ө .
android:layout_alignTop=@id+imageButton1 imageButton2 ң ғғ ө imageButton1 ң ғғ ғ ү.
android:layout_toRightOf=@id+imageButton1 imageButton2 imageButton1 ң ң ғ .
android:background=@drawble/a2 a2.png қ imageButton2 ң қ .
|
|
android:src="@drawable/abc_ab_share_pack_holo_dark" imageButton2 ү ғ.
3) Ә . Ә ү ImageButton ұ. ұ piano.xml құ. Ә ImageButton ү қ ғғ. қ Relative Layout қ. Ә ң ң құ ( 13):
<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:background="@drawable/background"
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="com.example.alippe.MainActivity$PlaceholderFragment" >
Ә ImageButton ү ә қ:
<ImageButton
android:id="@+id/imageButton1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true"
android:layout_marginLeft="58dp"
android:background="@drawable/key1"
android:src="@drawable/abc_ab_share_pack_holo_dark" />
ң 12- ө қ .
13. Ә ң
4) . paint.xml ү . ұ қ ң ө қ-қ қ қ қғ. Қ ү ү ң, қң ө ө, ң ә қ, ғ ө ү .
құ ұ, ұ қ қ . Res/values dimens.xml ә :
<!-- Brush sizes -->
<dimen name="small_brush">10dp</dimen>
<integer name="small_size">10</integer>
<dimen name="medium_brush">20dp</dimen>
<integer name="medium_size">20</integer>
<dimen name="large_brush">30dp</dimen>
<integer name="large_size">30</integer>
ғ қ құ. Қң ғ DrawingView құ. ұ ү :
public class DrawingView extends View
{
}
қ ә қ:
public DrawingView(Context context, AttributeSet attrs){
super(context, attrs);
setupDrawing();
}
XML ққ ө қ. қ ө ә қ:
private void setupDrawing(){
}
Қң қ үқ қ XML (res/values/strings.xml) :
|
|
<string name="start_new">New</string>
<string name="brush">Brush</string>
<string name="erase">Erase</string>
<string name="save">Save</string>
<string name="paint">Paint</string>
ң құ pain.xml ң құ :
<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:background="#FFCCCCCC"
android:orientation="vertical"
tools:context=".MainActivity" >
</LinearLayout>
Linear Layout :
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="50dp"
android:layout_gravity="center"
android:orientation="horizontal" >
</LinearLayout>
ұ Layout қ, қ , ө , ң құ. ұ ү қ:
- ң ;
- қ;
- ө;
- қ .
Ә ImageButton ә қң ө ә Linear Layout . ң ң құ ө:
<ImageButton
android:id="@+id/new_btn"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:contentDescription="@string/start_new"
android:src="@drawable/new_pic" />
Linear Layout құғ ө қ:
<com.example.drawingfun.DrawingView
android:id="@+id/drawing"
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_marginBottom="3dp"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:layout_marginTop="3dp"
android:layout_weight="1"
android:background="#FFFFFFFF" />
ә ң қ ғ, ғ қ қ ә Java- қ қ ғ ғ .
ү құ ү Linear layout ғ Linear Layout қ. ұ қ ұ. ң құғ :
<!-- Top Row -->
<LinearLayout
android:id="@+id/paint_colors"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal" >
</LinearLayout>
<!-- Bottom Row -->
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal" >
</LinearLayout>
құ қ, Java- қ, ғ, қ қғ ү қ ә ғ . Ә ү ү ImageButton құ қ:
|
|
<ImageButton
android:layout_width="@dimen/large_brush"
android:layout_height="@dimen/large_brush"
android:layout_margin="2dp"
android:background="#FF660000"
android:contentDescription="@string/paint"
android:onClick="paintClicked"
android:src="@drawable/paint"
android:tag="#FF660000" />
ғ ұ ә ( 14) :
14. ң