2016-03-31 38 views
0

Böyle bir kapsayıcıda iki görünüm var. Belirli bir değişken verilmediğinde view1'i gizlemek gibi i Bir Düzeni Yeniden Boyutlandırma

Şimdi ben bu soruyu bir milyar kez istendi biliyorum tüm ContainerView doldurmak için tamamen

  1. gizlemek view1
  2. resive view2 bir çözüm bulmak gibi görünüyor, ama bütün çözümler sadece olamaz

    düzen:

    ... benim için

    dont iş İşte kod parçalarıdır

    <?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> 
    

    ve ben Sofar requestLayout statik boyutlarda

  3. upperview.setVisibility(View.INVISIBLE); lowerview.getLayoutParams().height = 900;

Şerefe

alt düzeni için yeni bir RelativeLayout oluşturarak
  • ile is

    1. upperview.getLayoutParams().height = 0; lowerview.getLayoutParams().height = 900; mainview.invalidate()
    2. aynı çalıştı neyi

      Jacobus

  • +0

    VIew1.setVisiblity (VISIBLE.GONE) – Manifest

    +0

    @VarunKumar getLayoutParams(). Height = 0/900 ve benzer Düzen değişiklikleri, temelde diğer sorular için önerilen tek çözüm – PlatinTato

    +0

    Kodunuzu gönderin. Yukarıdaki soruyu düzenleyin ve şu ana kadar denediğiniz kodunuzu yayınlayın. –

    cevap

    1

    Bunu başarmak için ne denediğiniz konusunda emin değilim. Referansınız için, aynı çıktıyı elde etmek için kullanılan örnek bir kod yayınlıyorum.

    <?xml version="1.0" encoding="utf-8"?> 
    
    <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent"> 
    
    <RelativeLayout 
        android:id="@+id/rlView1" 
        android:layout_width="match_parent" 
        android:layout_height="wrap_content"> 
    
        <TextView 
         android:layout_width="wrap_content" 
         android:layout_height="wrap_content" 
         android:layout_centerInParent="true" 
         android:text="Text Field in View 1" /> 
    </RelativeLayout> 
    
    <RelativeLayout 
        android:id="@+id/rlView2" 
        android:layout_width="match_parent" 
        android:layout_height="match_parent" 
        android:layout_below="@+id/rlView1"> 
    
        <TextView 
         android:layout_width="wrap_content" 
         android:layout_height="wrap_content" 
         android:layout_centerInParent="true" 
         android:text="Text Field in View 2" /> 
    </RelativeLayout> 
    
    </RelativeLayout> 
    

    Eğer rlView2 ebeveyn aynı boyutta yapmak için rlView1.setVisiblity (View.GONE) kullanmak zorunda, unutmayın.

    +0

    tamamlandı, sadece xml'mi gönderdim. Bu rahatsızlıktan dolayı özür dilerim: D alttan görünen statik boyutta olması gerekiyor – PlatinTato

    +0

    'dan itibaren sadece çözümünüzü denedim işe yaramıyor. Statik boyutta rlView yaptım ve layout_below = rlView1 yaptı. sonra setVisibility (View.INVISIBLE) öğesini çağırıyorum, ancak yalnızca onu gizler ve diğer görünümler değişmez. EDIT View.GONE hile yapar ... Ben sadece retarded – PlatinTato

    +0

    Oh evet benim hata, VISIBLE.GONE yerine View.GONE olmalıdır –

    İlgili konular