Я пытаюсь создать приложение, где родительский компоновщик является прокручивать вид и добавить вид динамически этой компоновкой родителя, используя следующий код:Динамический вид получать вставлен весь экран Android
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);
}
Вот вид где я хочу, чтобы вставить вид:
<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>
А вот мнение, которое я хочу, чтобы вставить: 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>
Проблема заключается в том, что код вставляет всю страницу student_present_absent.xml. Так что я получаю полный экран student_present_absent.xml 5 раз, где я просто хочу, чтобы только 70DP макета повторялось 5 раз.
Пожалуйста, помогите.
Вы можете решить, что путем изменения 'андроида: layout_height' из' id: parent' to 'wrap_content' – hrskrs
Не работает, и я все еще получаю целую страницу. –
Я пробовал, и он отлично работает. Можете ли вы загрузить scrennshot? – hrskrs