Dynamic view getting inserted with whole screen android -
i trying create app parent layout scrollable view , add view dynamically parent layout using following code:
linearlayout ll = (linearlayout) findviewbyid(r.id.parent); for(int i=0;i<5;i++){ layoutinflater inflater = (layoutinflater) getsystemservice( context.layout_inflater_service ); view format = inflater.inflate(r.layout.student_present_absent,null); ll.addview(format); }
here view want insert view:
<linearlayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" android:background="@drawable/backgroundf" android:weightsum="8" android:id="@+id/takeattendanceinterim"> <linearlayout android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="0dp" android:layout_weight="1.1"> <linearlayout android:orientation="horizontal" android:layout_width="match_parent" android:layout_height="match_parent" android:weightsum="10"> <linearlayout android:orientation="vertical" android:layout_width="0dp" android:layout_height="match_parent" android:layout_weight="2"> <imagebutton android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/blogoimage" android:src="@drawable/icwhitehouse" android:layout_gravity="right" android:layout_margin="5dp" android:background="@null"/> </linearlayout> <linearlayout android:orientation="vertical" android:layout_width="0dp" android:layout_height="match_parent" android:layout_weight="6" android:layout_gravity="center_vertical"> <linearlayout android:orientation="vertical" android:layout_width="match_parent" android:layout_height="0dp" android:layout_weight="3" android:layout_gravity="center_vertical"> <textview android:layout_width="fill_parent" android:layout_height="fill_parent" android:textappearance="?android:attr/textappearancemedium" android:text="class 5 section a" android:id="@+id/tclassandsection" android:textcolor="@color/white" android:gravity="center" android:layout_margintop="1dp" android:textstyle="normal" android:textsize="20dp"/> </linearlayout> <linearlayout android:orientation="vertical" android:layout_width="match_parent" android:layout_height="0dp" android:layout_weight="3" android:layout_gravity="center_vertical"> <textview android:layout_width="fill_parent" android:layout_height="fill_parent" android:textappearance="?android:attr/textappearancemedium" android:text="07 feb 2016" android:id="@+id/tdate" android:textcolor="@color/white" android:gravity="center" android:layout_margintop="1dp" android:textstyle="normal" android:textsize="20dp"/> </linearlayout> </linearlayout> <linearlayout android:orientation="vertical" android:layout_width="0dp" android:layout_height="match_parent" android:layout_weight="2"> <imagebutton android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/blogout" android:src="@drawable/iclogoffsmallest" android:gravity="center" android:layout_margin="20dp" android:background="@null"/> </linearlayout> </linearlayout> </linearlayout> <linearlayout android:orientation="vertical" android:layout_width="match_parent" android:layout_height="0dp" android:layout_weight="0.2"> <view android:layout_width="fill_parent" android:layout_height="0.1dp" android:background="#ffffff" /> </linearlayout> <linearlayout android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="0dp" android:layout_weight="7"> <linearlayout android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="0dp" android:layout_weight="4"> <scrollview android:id="@+id/studentnames" android:layout_width="match_parent" android:layout_height="match_parent" android:fillviewport="true"> <linearlayout android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent" android:id="@+id/parent"> </linearlayout> </scrollview> </linearlayout> <linearlayout android:orientation="vertical" android:layout_width="match_parent" android:layout_height="0dp" android:layout_weight="0.2"> <view android:layout_width="fill_parent" android:layout_height="0.1dp" android:background="#ffffff" /> </linearlayout> <linearlayout android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="0dp" android:layout_weight="0.5"> <linearlayout android:orientation="horizontal" android:layout_width="match_parent" android:layout_height="match_parent" android:weightsum="10"> <linearlayout android:orientation="vertical" android:layout_width="0dp" android:layout_height="match_parent" android:layout_weight="5"> <button android:id="@+id/bmarkallpresent" android:text="all present" android:layout_width="fill_parent" android:layout_height="fill_parent" android:layout_marginbottom="0dp" android:layout_marginleft="1dp" android:layout_marginright="1dp" android:textsize="15dp"/> </linearlayout> <linearlayout android:orientation="vertical" android:layout_width="0dp" android:layout_height="match_parent" android:layout_weight="5" android:layout_gravity="center_vertical"> <button android:id="@+id/bmarkallabsent" android:text="all absent" android:layout_width="fill_parent" android:layout_height="fill_parent" android:layout_marginbottom="0dp" android:layout_marginleft="1dp" android:layout_marginright="1dp" android:textsize="15dp"/> </linearlayout> </linearlayout> </linearlayout> <linearlayout android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="0dp" android:layout_weight="0.7"> <button android:id="@+id/bcontinuetotakeattendance" android:text="submit" android:layout_width="fill_parent" android:layout_height="fill_parent" android:layout_marginbottom="2dp" android:layout_marginleft="1dp" android:layout_marginright="1dp" android:textsize="15dp"/> </linearlayout> </linearlayout> </linearlayout>
and here view want insert: student_present_absent.xml
<linearlayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="70dp" android:orientation="vertical" android:background="@drawable/backgroundf" android:id="@+id/abcdef"> <linearlayout android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="65dp" android:id="@+id/student_present_absent"> <linearlayout android:orientation="horizontal" android:layout_width="match_parent" android:layout_height="match_parent" android:weightsum="10"> <linearlayout android:orientation="vertical" android:layout_width="0dp" android:layout_height="match_parent" android:layout_weight="2"> <imagebutton android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/blogoimage" android:src="@drawable/icwhitehouse" android:layout_gravity="right" android:layout_margin="5dp" android:background="@null"/> </linearlayout> <linearlayout android:orientation="vertical" android:layout_width="0dp" android:layout_height="match_parent" android:layout_weight="5" android:layout_gravity="center_vertical"> </linearlayout> <linearlayout android:orientation="vertical" android:layout_width="0dp" android:layout_height="match_parent" android:layout_weight="1.5"> <imagebutton android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/blogout" android:src="@drawable/iclogoffsmallest" android:gravity="center" android:layout_margin="2dp" android:background="@null"/> </linearlayout> <linearlayout android:orientation="vertical" android:layout_width="0dp" android:layout_height="match_parent" android:layout_weight="1.5"> <imagebutton android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/blogout1" android:src="@drawable/iclogoffsmallest" android:gravity="center" android:layout_margin="2dp" android:background="@null"/> </linearlayout> </linearlayout> </linearlayout> <linearlayout android:orientation="vertical" android:layout_width="match_parent" android:layout_height="5dp" android:id="@+id/whiteline1"> <view android:layout_width="fill_parent" android:layout_height="0.1dp" android:background="#ffffff" /> </linearlayout> </linearlayout>
the problem code inserts whole page of student_present_absent.xml full screen of student_present_absent.xml 5 times, want 70dp of layout repeated 5 times.
please help.
this sounds usecase listview/recyclerview multiple layouts.
using google found following link... didn't test looks quite @ first sight:
http://www.survivingwithandroid.com/2014/08/android-listview-with-multiple-row.html
Comments
Post a Comment