d91 d91 - 9 months ago 29
Android Question

nested linearlayout not appearing..gives black space

Hi i am new to android programming. In my app I have nested layouts. following is my activity_main.xml file

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/activity_main"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="0dp"
android:paddingLeft="0dp"
android:paddingRight="0dp"
android:paddingTop="0dp"
tools:context="com.tdapps.play_video.MainActivity"
android:background="?android:attr/actionModeSplitBackground">
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">

<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
app:srcCompat="@android:color/black"
android:layout_weight="1"
android:id="@+id/imageView" />

<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="10"
>

<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/imgoverlay">

<Button
android:text="Import Image"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:id="@+id/Importimage"
android:layout_weight="1"
android:textAllCaps="false"
android:textSize="18sp"
android:textStyle="bold"
android:background="#00ffff"
android:textColor="#000000"
style="?android:attr/borderlessButtonStyle"
/>
</LinearLayout>

<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/vignette">

<SeekBar
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/vseekbar"
android:layout_weight="1" />
</LinearLayout>

<LinearLayout
android:id="@+id/color"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:orientation="horizontal">

<Button
android:id="@+id/Grayscale"
style="?android:attr/borderlessButtonStyle"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="#00ffff"
android:text="Grayscale"
android:textAllCaps="false"
android:textColor="#000000"
android:textSize="18sp"
android:textStyle="bold" />

<Button
android:id="@+id/Negative"
style="?android:attr/borderlessButtonStyle"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="#00ffff"
android:text="Negative"
android:textAllCaps="false"
android:textColor="#000000"
android:textSize="18sp"
android:textStyle="bold" />

</LinearLayout>






<HorizontalScrollView

android:layout_width="match_parent"
android:layout_height="match_parent"
android:scrollbars="none"
android:background="#000000"
android:id="@+id/blurview">

<LinearLayout
android:id="@+id/filter"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:orientation="horizontal">

<Button
android:id="@+id/BilateralFilter"
style="?android:attr/borderlessButtonStyle"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:background="#00ffff"
android:text="Bilateral"
android:textAllCaps="false"
android:textColor="#000000"
android:textSize="18sp"
android:textStyle="bold" />

<Button
android:id="@+id/median"
style="?android:attr/borderlessButtonStyle"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:background="#00ffff"
android:text="Median"
android:textAllCaps="false"
android:textColor="#000000"
android:textSize="18sp"
android:textStyle="bold" />

<Button
android:id="@+id/blur1"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="#00ffff"
android:text="Blur Level 1"
android:textAllCaps="false"
android:textColor="#000000"
android:textSize="18sp"
android:textStyle="bold"


/>

<Button
android:id="@+id/blur2"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="#00ffff"
android:text="Blur Level 2"
android:textAllCaps="false"
android:textColor="#000000"
android:textSize="18sp"
android:textStyle="bold"


/>

<Button
android:id="@+id/blur3"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="#00ffff"
android:text="Blur Level 3"
android:textAllCaps="false"
android:textColor="#000000"
android:textSize="18sp"
android:textStyle="bold" />

<Button
android:id="@+id/blur4"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="#00ffff"
android:text="Blur Level 4"
android:textAllCaps="false"
android:textColor="#000000"
android:textSize="18sp"
android:textStyle="bold" />

<Button
android:id="@+id/blur5"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="#00ffff"
android:text="Blur Level 5"
android:textAllCaps="false"
android:textColor="#000000"
android:textSize="18sp"
android:textStyle="bold" />

<Button
android:id="@+id/blur6"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="#00ffff"
android:text="Blur Level 6"
android:textAllCaps="false"
android:textColor="#000000"
android:textSize="18sp"
android:textStyle="bold" />

</LinearLayout>
</HorizontalScrollView>


<LinearLayout
android:id="@+id/light"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal">

<Button
android:id="@+id/Brightness"
style="?android:attr/borderlessButtonStyle"
android:layout_width="80dp"
android:layout_height="match_parent"
android:background="#00ffff"
android:text="Brightness"
android:textAllCaps="false"
android:textColor="#000000"
android:textSize="18sp"
android:textStyle="bold" />

<Button
android:id="@+id/Contrast"
style="?android:attr/borderlessButtonStyle"
android:layout_width="80dp"
android:layout_height="match_parent"
android:background="#00ffff"
android:text="Contrast"
android:textAllCaps="false"
android:textColor="#000000"
android:textSize="18sp"
android:textStyle="bold" />

<SeekBar
android:id="@+id/seekBar2"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#00ffff"
android:max="255" />
</LinearLayout>

<HorizontalScrollView

android:id="@+id/main"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#000000"
android:scrollbars="none">

<LinearLayout
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:orientation="horizontal">

<Button
android:id="@+id/Lightning"
style="?android:attr/borderlessButtonStyle"
android:layout_width="80dp"
android:layout_height="match_parent"

android:background="#00ffff"
android:text="Lightning"
android:textAllCaps="false"
android:textColor="#000000"
android:textSize="18sp"
android:textStyle="bold" />

<Button
android:id="@+id/Filter"
style="?android:attr/borderlessButtonStyle"
android:layout_width="80dp"
android:layout_height="match_parent"
android:background="#00ffff"
android:text="Filter"
android:textAllCaps="false"
android:textColor="#000000"
android:textSize="18sp"
android:textStyle="bold" />


<Button
android:id="@+id/Crop"
style="?android:attr/borderlessButtonStyle"
android:layout_width="80dp"
android:layout_height="match_parent"

android:background="#00ffff"
android:text="Crop"
android:textAllCaps="false"
android:textColor="#000000"
android:textSize="18sp"
android:textStyle="bold" />

<Button
android:id="@+id/Color"
style="?android:attr/borderlessButtonStyle"
android:layout_width="80dp"
android:layout_height="match_parent"

android:background="#00ffff"
android:text="Color"
android:textAllCaps="false"
android:textColor="#000000"
android:textSize="18sp"
android:textStyle="bold" />

<Button
android:id="@+id/Rotate"
style="?android:attr/borderlessButtonStyle"
android:layout_width="80dp"
android:layout_height="match_parent"

android:background="#00ffff"
android:text="Rotate"
android:textAllCaps="false"

android:textColor="#000000"
android:textSize="18sp"
android:textStyle="bold" />

<Button
android:id="@+id/Vignette"
style="?android:attr/borderlessButtonStyle"
android:layout_width="80dp"
android:layout_height="match_parent"

android:background="#00ffff"
android:text="Vignette"
android:textAllCaps="false"
android:textColor="#000000"
android:textSize="18sp"
android:textStyle="bold" />

<Button
android:id="@+id/ImgOverlay"
style="?android:attr/borderlessButtonStyle"
android:layout_width="80dp"
android:layout_height="match_parent"

android:background="#00ffff"
android:text="Image Overlay"
android:textAllCaps="false"
android:textColor="#000000"
android:textSize="18sp"
android:textStyle="bold" />

<Button
android:id="@+id/PutText"
style="?android:attr/borderlessButtonStyle"
android:layout_width="80dp"
android:layout_height="match_parent"
android:background="#00ffff"
android:text="Put Text"
android:textAllCaps="false"
android:textColor="#000000"
android:textSize="18sp"
android:textStyle="bold" />
</LinearLayout>
</HorizontalScrollView>

</RelativeLayout>

</LinearLayout>




so when I set setvisibility for both filter and light layouts they appears and works fine. but when i set setvisibility for color layout it shows blank space for that layout(i mean image view exists . the layout under the imageview is not appearing. but getvisibility tells that layout is visible). I tried changing layout width,height with wrap content,match parent but still giving the same result. why this linear layout (for "color") is not appearing? how to solve this. thanks

Answer Source

Though you set main layout invisible, light and blurview layouts are still above color layout. RelativeLayout works as stacks. The later layouts appear first. I copied your codes. I set main, light and blurview invisible, then the color layout appeared.

Here is the color layout.

enter image description here