2016-03-31 13 views
0

このようなコンテナには2つのビューがあります。レイアウトのサイズ変更

[ContainerView  
[view 1 (RelativeLayout)]  
[view 2 (RelativeLayout)]  
(Relative Layout)] 

idは、特定の変数が指定されていない場合は常にview1を非表示にします。私は今、私は単にこの質問は10億回を頼まれました知っているが、すべてのソリューション全体ContainerViewに

を埋めるために

  1. 非表示VIEW1完全
  2. resive VIEW2への解決策を見つけるように見えるカント私のために仕事をいけない...ここで

    は、コードの一部です:

    レイアウト:

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

    と私はrequestLayout

  3. は静的サイズの低いレイアウト
  4. upperview.setVisibility(View.INVISIBLE); lowerview.getLayoutParams().height = 900;

乾杯のための新しいRelativeLayoutを作成同じ

  1. upperview.getLayoutParams().height = 0; lowerview.getLayoutParams().height = 900; mainview.invalidate()
  2. IS SOFAR試み

    ヤコブス

+0

VIew1.setVisiblity(VISIBLE.GONE) – Manifest

+0

@VarunKumar getLayoutParams()。高さ= 0/900、および同様のレイアウトの変更は、基本的には他の質問のために提案なっている唯一の解決策は、あなたのコードを投稿 – PlatinTato

+0

。上記の質問を編集し、これまでに試したコードを投稿してください。 –

答えて

1

これを達成するために既に試したことについてはわかりません。参考のため、同じ出力を達成するために使用されるサンプルコードを掲載しています。

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

あなたがrlView2親のと同じ大きさにするためにrlView1.setVisiblity(View.GONE)を使用する必要が、あることに注意してください。

+0

私はちょうど私のXMLを投稿しました。私はその不便をおかけして申し訳ありません:私は初めから静的なサイズの下側のビューを必要とする – PlatinTato

+0

私はあなたのソリューションを試しただけでは動作しないようだ。静的なサイズのrlViewを作成し、layout_below = rlView1を実行しました。私はsetVisibility(View.INVISIBLE)を呼び出しますが、それは隠すだけで、他のビューのサイズは変わりません。 View.GONEはトリックを行います...私はちょうど遅らせたと思います – PlatinTato

+0

ああ私の間違い、VISIBLE.GONEの代わりにView.GONE –