java - ImageView is NOT SHOWING in a linear layout (android) -
i'm creating android application , got issues in first stage.
i'm trying display image imageview inside layout.
my code follows:
activity_starter.xml:
<linearlayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="fill_parent" android:layout_height="fill_parent" android:background="@color/white" 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=".starteractivity" > <imageview android:id="@+id/starterpic" android:layout_width="0dp" android:layout_height="160dp" android:layout_gravity="center" android:layout_weight="0.84" android:adjustviewbounds="true" android:contentdescription="@string/app_name" android:src="@drawable/ic_launcher" android:visibility="visible" /> </linearlayout>
and starteractivity.java:
protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_starter); log.i(log_tag, "entered starter screen"); imageview mimageview = (imageview) findviewbyid(r.id.starterpic); mimageview.setscaletype(imageview.scaletype.fit_center); mimageview.setimageresource(r.drawable.ic_launcher); mimageview.setvisibility(imageview.visible); mimageview.invalidate(); }
the issues are:
- i can't hide title bar on top (black bar says "whereisit" (app. name)).
- the image in imageview not shown.
i've been digging hours, doing wrong?
to hide title bar
, need put code in oncreate
method :
@override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); requestwindowfeature(window.feature_no_title); //add line setcontentview(r.layout.activity_starter); // rest of code }
Comments
Post a Comment