Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

android - overdraw layout allows touch through LinearLayout

in the following UI I have this below drabable overlaying the entire screen. The LinearLayout is transparent and allows controls below it to be clickable or touchable. Basically I can scroll a list below this LinearLayout as well as click controls. How do I disable that?

See attached example.enter image description here

Thank you

<RelativeLayout
     xmlns:android="http://schemas.android.com/apk/res/android" 
    android:id="@+id/rlExtNavbar" 
    android:orientation="vertical"
    android:layout_width="match_parent" 
    android:layout_height="match_parent"
    android:gravity="fill_vertical"
    android:layout_gravity="fill_vertical"
    android:background="@color/transparent" xmlns:tools="http://schemas.android.com/tools" tools:ignore="Overdraw">
    <RelativeLayout
        android:id="@+id/expandedNavbarLayout" 
        android:orientation="vertical"
        android:layout_width="fill_parent" 
        android:layout_height="wrap_content" >
    </RelativeLayout>
    <LinearLayout
        android:id="@+id/transparentLayout" 
        android:orientation="vertical"
        android:layout_width="match_parent" 
        android:layout_height="wrap_content"
        android:layout_below="@id/expandedNavbarLayout"
        android:focusableInTouchMode="false"
        android:focusable="false"
        android:background="@color/fulltransparent">
    </LinearLayout>

</RelativeLayout>
like image 485
dropsOfJupiter Avatar asked Apr 12 '12 17:04

dropsOfJupiter


People also ask

What is the use of LinearLayout in android Studio?

LinearLayout is a view group that aligns all children in a single direction, vertically or horizontally. You can specify the layout direction with the android:orientation attribute. Note: For better performance and tooling support, you should instead build your layout with ConstraintLayout.

What is RelativeLayout and LinearLayout in android?

Android Layout TypesLinearLayout : is a ViewGroup that aligns all children in a single direction, vertically or horizontally. RelativeLayout : is a ViewGroup that displays child views in relative positions. AbsoluteLayout : allows us to specify the exact location of the child views and widgets.

Which layout is faster in android?

Measurement results: ConstraintLayout is faster As these results show, ConstraintLayout is likely to be more performant than traditional layouts. Moreover, ConstraintLayout has other features that help you build complex and performant layouts, as discussed in the benefits of a ConstraintLayout object section.

What is the default orientation of a LinearLayout?

The default orientation is horizontal.


1 Answers

Just setting the android:clickable="true" property for the LinearLayout in the XML will prevent the clicks going through -- no need for a click listener.

like image 86
Theo Avatar answered Sep 20 '22 11:09

Theo