我在这样的容器中有两个视图。调整布局的尺寸
[ContainerView
[view 1 (RelativeLayout)]
[view 2 (RelativeLayout)]
(Relative Layout)]
和id喜欢隐藏view1每当某个变量没有给出。我似乎无法找到解决
- 皮厂景完全
- resive视图2填满整个ContainerView
现在我知道这个问题已经被问了十亿次,但所有的解决方案,简单地不工作对我来说...
下面是部分代码:
布局:
<?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>
,什么我想SOFAR就是
upperview.getLayoutParams().height = 0; lowerview.getLayoutParams().height = 900; mainview.invalidate()
- 同样与requestLayout
- 与静态大小
upperview.setVisibility(View.INVISIBLE); lowerview.getLayoutParams().height = 900;
干杯
较低布局创建一个新的RelativeLayout雅各布斯
VIew1.setVisiblity(VISIBLE.GONE) – Manifest
@VarunKumar getLayoutParams()。height = 0/900,和类似的布局变化,基本上是获得其他问题的唯一解决方案 – PlatinTato
发布您的代码。编辑上面的问题,并发布你迄今为止尝试过的代码。 –