java - Setting content view hierarchy -
i'm developing app implements simple compass.
i'm creating , manipulating compass in class (rose.java) extends imageview.
on main activity want add rose object layout , have code
 public void oncreate(bundle savedinstancestate) {   super.oncreate(savedinstancestate);    sensormanager = (sensormanager) getsystemservice(sensor_service);   sensor = sensormanager.getdefaultsensor(sensor.type_orientation);    rose = new rose (this);     setcontentview(rose);   }   the thing is, know, using setcontentview "rose" going full screen , rest of elements of layout won't show.
i'm asking alternate method adds rose object layout without neglecting rest of elements.
thanks in advance.
you allocate width , height of linearlayout in xml.
define linearlayout in xml file , define width , height of choice. place layout like. add content of custom view linearlayout
   setcontentview(r.id.activity_main);    linearlayout ll =  (linearlayout) findviewbyid(r.id.linearlayout);    rose = new rose(this);    ll.addview(rose);   example:
actiivty_main.xml
<relativelayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent"  >    // other views textview's , button above linear layout     <linearlayout        android:layout_width="40dp" // mention width of choice        android:layout_height="40dp"  // // mention height of choice        android:layout_above="@+id/button1"        android:layout_alignparentright="true"        android:id="@+id/linearlayout"        >    </linearlayout>         // other views below linear layout </relativelayout>      
Comments
Post a Comment