Mobile Computing Systems
Download 10.9 Kb.
|
- Bu sahifa navigatsiya:
- 1(b) XML with drawable properties
- Nine Patch Image
1. Using Drawables
1(a) Image from Project Resource
<ImageView android:layout_width="match_parent" android:layout_height="wrap_content" android:id="@+id/img1" android:src="@drawable/my_image"/> ImageView i = new ImageView(this); i.setImageResource(R.drawable.my_image); LinearLayout ll = new LinearLayout(this); ll.addView(i); setContentView(ll); //instead of setContentView(R.layout.somexmllayoutfile) 1(b) XML with drawable properties
<transition xmlns:android="http://schemas.android.com/apk/res/android"> <item android:drawable="@drawable/image1"> <item android:drawable="@drawable/image2"> transition> TransitionDrawable td; td = (TransitionDrawable) getResources().getDrawable(R.drawable.something); td.setCrossFadeEnabled(true); ImageView img; img = (ImageView) findViewById(R.id.img1); img.setImageDrawable(td); td.startTransition(5000); Nine Patch Image
From a terminal: Run the draw9patch command from your SDK sdk/tools directory to launch the tool. 2. Using Canvas
Bitmap b = Bitmap.createBitmap(100, 100, Bitmap.Config.ARGB_8888); Canvas c = new Canvas(b); Paint p = new Paint(); p.setColor(Color.GREEN); c.drawRect(10, 10, 90, 90, p); Download 10.9 Kb. Do'stlaringiz bilan baham: |
Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©fayllar.org 2024
ma'muriyatiga murojaat qiling
ma'muriyatiga murojaat qiling