Resize ImageView Image in View Android Example
How to resize an image in ImageView Android source code.
Resize imageview layout and image will resize too:
Resize imageview layout and image will resize too:
public void resizeImageView(int width, int height) {
final ImageView picture1 = (ImageView)findViewById(R.id.imageView1);
LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(width, height);
picture1.setLayoutParams(layoutParams);
}
396LW NO topic_id
AD
Další témata ....(Topics)
No resource found that matches the given name - error examples.
Exist resource file?
Is code written correctly?
Exist resource file?
Is code written correctly?
// No resource found that matches the given name (at id with value @id/myButton).
android:id="@id/myButton" // invalid id notation
android:id="@+id/myButton" // correct
// No resource found that matches the given name
// (at icon with value @drawable/icons).
// exist file icons in res/drawable folder?
<application android:icon="@drawable/icons"
//No resource found that matches the given name
//(at theme with value @style/MyThem).
<activity android:name=".Main"
android:label="@string/app_name"
android:theme="@style/MyThem">
// Exist style MyThem in styles.xml ? No only MyTheme
<style name="MyTheme" parent="android:Theme">
<item name="android:windowTitleSize">50px</item>
</style>
// exist file my_background in folder drawable ?
android:background="@drawable/my_background" //
// no resource found that matches the given name(at "label" with value "@string/app_name")
// have you the string resource defined in res/values/strings.xml ?
<string name="app_name">"My App"</string>
public class MainClass extends Activity {
ActivityManager activityManager;
MemoryInfo memoryInfo;
final String TAG = "MemInfo";
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
activityManager = (ActivityManager) getSystemService(ACTIVITY_SERVICE);
memoryInfo = new ActivityManager.MemoryInfo();
activityManager.getMemoryInfo(memoryInfo);
Log.i(TAG, " memoryInfo.availMem " + memoryInfo.availMem);
Log.i(TAG, " memoryInfo.lowMemory " + memoryInfo.lowMemory);
Log.i(TAG, " memoryInfo.threshold " + memoryInfo.threshold);
Toast.makeText(getApplicationContext(), String.valueOf( memoryInfo.availMem), Toast.LENGTH_LONG)
.show();
} // end onCreate
}
Activities launcher
public class MainActivity extends ListActivity {
private class Sample {
private CharSequence title;
private Class<? extends Activity> activityClass;
public Sample(int titleResId, Class<? extends Activity> activityClass) {
this.activityClass = activityClass;
this.title = getResources().getString(titleResId);
}
@Override
public String toString() {
return title.toString();
}
}
private static Sample[] mSamples;
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
// Instantiate the list of samples.
mSamples = new Sample[]{
new Sample(R.string.title_first_app, FirstActivity.class),
new Sample(R.string.title_second_app, SecondActivity.class),
new Sample(R.string.title_third_app, ThirdActivity.class),
};
setListAdapter(new ArrayAdapter<Sample>(this,
android.R.layout.simple_list_item_1,
android.R.id.text1,
mSamples));
}
@Override
protected void onListItemClick(ListView listView, View view, int position, long id) {
// Launch the sample associated with this list position.
startActivity(new Intent(MainActivity.this, mSamples[position].activityClass));
}
}
Click Handler Android Java example source code. Open new class as activity and open URL in browser.
In layout.xml file:
In string.xml
In MainClass.java file
In layout.xml file:
android:layout_height="wrap_content" android:onClick="@string/clickHandler">
In string.xml
myClickHandler
In MainClass.java file
public void myClickHandler(View view) {
switch (view.getId()) {
// open new class as activity
case R.id.btnOpenClass: {
Intent pictureActivity = new Intent(getBaseContext(),
MyClass.class);
startActivity(pictureActivity);
}
break;
case R.id.btnAbout: {
//aboutDialogCreate();
}
break;
// open url
case R.id.btnHome: {
String url = "//android.okhelp.cz/";
Intent i = new Intent(Intent.ACTION_VIEW);
i.setData(Uri.parse(url));
startActivity(i);
}break;
}
}// end myClickHandler
// listener .. if click on button will scrolling to mTextView bottom
private OnClickListener mButtonListener = new OnClickListener() {
public void onClick(View v) {
// do something when the button is clicked
int nBottom = mTextView.getBottom();
hScrollView.scrollTo(0, nBottom);
}
};
HTC Desire HD cena od 7 000 KCZ Kč (únor.2012)
HTC Desire HD je chytrý telefon běžící na operačním systému Android.
HTC Desire HD je (22.února2012) druhým nejpoužívanějším chytrým telefonem u programu Sky Map viz tabulka.
Smartphone má hliníkový unibody design, vybaven je Androidem 2.2 (Froyo) a HTC Sense displayem. Na zadní straně jsou dvě plastové krytky, jedna obsahuje baterii, druhá SIM kartu a paměťovou kartu microSDHC. Telefon je vybaven 4,3 palcovým WVGA LCD TFT dotykovým displayem, 8 megapixelovým fotoaparátem (lze nahrávat 720p video), podpora pro HSPA / W-CDMA a quad-band GSM / GPRS / EDGE.
Telefon je vybaven 1 GHz CPU Scorpion MSM8255 procesorem. Tato druhá generace Snapdragon procesoru má nízkou spotřebu energie.
HTC HD má 768 MB RAM a 1,5 GB interní paměti flash. K dispozici je také slot pro microSDHC / XC kartu s kapacitou až 32 GB dat.
HTC Desire HD photo pic image
Zdroj obrázku: wikipedia
HTC Desire HD je chytrý telefon běžící na operačním systému Android.
HTC Desire HD je (22.února2012) druhým nejpoužívanějším chytrým telefonem u programu Sky Map viz tabulka.
Smartphone má hliníkový unibody design, vybaven je Androidem 2.2 (Froyo) a HTC Sense displayem. Na zadní straně jsou dvě plastové krytky, jedna obsahuje baterii, druhá SIM kartu a paměťovou kartu microSDHC. Telefon je vybaven 4,3 palcovým WVGA LCD TFT dotykovým displayem, 8 megapixelovým fotoaparátem (lze nahrávat 720p video), podpora pro HSPA / W-CDMA a quad-band GSM / GPRS / EDGE.
Telefon je vybaven 1 GHz CPU Scorpion MSM8255 procesorem. Tato druhá generace Snapdragon procesoru má nízkou spotřebu energie.
HTC HD má 768 MB RAM a 1,5 GB interní paměti flash. K dispozici je také slot pro microSDHC / XC kartu s kapacitou až 32 GB dat.
HTC Desire HD photo pic image
Zdroj obrázku: wikipedia
Editace: 2013-12-09 13:01:41
Počet článků v kategorii: 396
Url:resize-imageview-image-in-view-android-example