Ich habe zwei Sicht in einem Container wie folgt.Die Größe eines Layouts ändern
[ContainerView
[view 1 (RelativeLayout)]
[view 2 (RelativeLayout)]
(Relative Layout)]
und id gerne view1 ausblenden, wenn eine bestimmte Variable nicht gegeben ist. Ich kann nicht scheinen, um eine Lösung zu
- hide view1 vollständig
- resive Ansicht2 finden Sie die gesamte ContainerView
Nun ich diese Frage wissen zu füllen hat eine Milliarde Mal gefragt worden, aber alle Lösungen einfach arbeiten nicht für mich ...
Hier sind Teile des Codes:
Layout:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#eeeeee"
android:id="@+id/mainview">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_marginLeft="0dp"
android:layout_marginBottom="50dp"
android:elevation="4dp"
android:background="@android:color/white"
android:layout_alignParentTop="true"
android:id="@+id/header">
<TextView
android:id="@+id/headertext"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@android:color/white"
android:text="Large Text"
android:padding="15dp"
android:textColor="@android:color/black"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textSize="50dp"
android:layout_marginLeft="0dp"
android:layout_marginRight="0dp"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true" />
</RelativeLayout>
<RelativeLayout
android:id="@+id/upperview"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_alignParentStart="true"
android:layout_below="@+id/lowerview"
android:layout_above="@+id/header">
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@android:color/white"
android:elevation="4dp"
android:id="@+id/vanisherView"
android:layout_centerHorizontal="true"
android:layout_margin="20dp">
<TextView
android:id="@+id/erklareung"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textColor="@android:color/black"
android:background="@android:color/white"
android:padding="40dp"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textSize="35dp"
android:layout_alignParentTop="true"
android:layout_alignParentEnd="true" />
</LinearLayout>
</RelativeLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="470dp"
android:id="@+id/lowerview"
android:padding="20dp"
android:background="@android:color/white"
android:elevation="4dp"
android:layout_above="@+id/bottom">
</RelativeLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingBottom="20dp"
android:paddingLeft="20dp"
android:paddingRight="20dp"
android:layout_marginLeft="0dp"
android:id="@+id/bottom"
android:paddingTop="30dp"
android:layout_alignParentBottom="true">
<Button
android:id="@+id/back"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Button"
android:textSize="30dp" />
<Button
android:id="@+id/nextButton"
android:layout_width="match_parent"
android:layout_height="80dp"
android:layout_weight="0.5"
android:text="Button"
android:textSize="30dp"
android:background="#009688"
android:textColor="#ffffff" />
</LinearLayout>
</RelativeLayout>
und was ich versuchte sofar heißt
upperview.getLayoutParams().height = 0; lowerview.getLayoutParams().height = 900; mainview.invalidate()
- gleiche mit requestLayout
- ein neues RelativeLayout für die untere Layout mit statischen Größen
upperview.setVisibility(View.INVISIBLE); lowerview.getLayoutParams().height = 900;
Beifall Schaffung
Jacobus
VIew1.setVisiblity (VISIBLE.GONE) – Manifest
@VarunKumar getLayoutParams(). Height = 0/900 und ähnliche Layout-Änderungen, im Grunde die einzige Lösung, die für andere Fragen vorgeschlagen wird immer – PlatinTato
Code veröffentlichen. Bearbeiten Sie die obige Frage und geben Sie Ihren Code ein, den Sie bisher ausprobiert haben. –