0

Im trying to show / hide a specifically ImageView, that it's inside a FrameLayout. At the same time, im gonna hide or show (on the contrary to ImageView), the LinearLayout with id recents_linear_layout

<com.android.systemui.recent.RecentsPanelView
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/recents_root"
android:layout_height="match_parent"
android:layout_width="match_parent">

<FrameLayout
    android:id="@+id/recents_bg_protect"
    android:background="@drawable/status_bar_recents_background"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_alignParentBottom="true"
    android:clipToPadding="false"
    android:clipChildren="false">

    <com.android.systemui.recent.RecentsHorizontalScrollView android:id="@+id/recents_container"
        android:layout_width="wrap_content"
        android:layout_height="match_parent"
        android:layout_marginRight="@dimen/status_bar_recents_right_glow_margin"
        android:divider="@null"
        android:stackFromBottom="true"
        android:fadingEdge="horizontal"
        android:scrollbars="none"
        android:fadingEdgeLength="@dimen/status_bar_recents_fading_edge_length"
        android:layout_gravity="bottom|left"
        android:orientation="horizontal"
        android:clipToPadding="false"
        android:clipChildren="false">

        <LinearLayout android:id="@+id/recents_linear_layout"
            android:layout_width="wrap_content"
            android:layout_height="match_parent"
            android:orientation="horizontal"
            android:clipToPadding="false"
            android:clipChildren="false">
        </LinearLayout>


    </com.android.systemui.recent.RecentsHorizontalScrollView>

**<ImageView android:id="@+id/landscape"
    android:gravity="center"
    android:layout_gravity="center"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_marginTop="0.0dip"
    android:src="@drawable/landscape_img"
    android:visibility="gone" />**

</FrameLayout>

<include layout="@layout/status_bar_no_recent_apps"
    android:id="@+id/recents_no_apps"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:visibility="invisible" />

</com.android.systemui.recent.RecentsPanelView>

My java code, throws a NullPointerException, because it cant find the ImageView (because this is being executed on com.android.systemui.recent.RecentsHorizontalScrollView. This is the code

    mLinearLayout = (LinearLayout) findViewById(R.id.recents_linear_layout);
    mLinearLayout.setVisibility(mRecent ? LinearLayout.GONE : LinearLayout.VISIBLE);
mLandScape = (ImageView) findViewById(R.id.landscape);
mLandScape.setVisibility(mRecent ? View.VISIBLE : View.GONE);

Thanks in advance.

user809486
  • 888
  • 1
  • 7
  • 15

2 Answers2

0

you could use ((Activity)getContext()).findViewById(R.id.landscape) though you should avoid it since there is no guarantee that the context is an activity. I can't understand why you are trying to hide some views inside this view. I think this is the activity's responsibility. You should make some interface with call back method to notify the activity about your event then let it hide the image view.

Mahdi Hijazi
  • 4,424
  • 3
  • 24
  • 29
0

FIXED Fix was making a external layout container with old Layout and ImageView as childs

    <com.android.systemui.recent.RecentsHorizontalScrollView android:id="@+id/recents_container"
        android:layout_width="wrap_content"
        android:layout_height="match_parent"
        android:layout_marginRight="@dimen/status_bar_recents_right_glow_margin"
        android:divider="@null"
        android:stackFromBottom="true"
        android:fadingEdge="horizontal"
        android:scrollbars="none"
        android:fadingEdgeLength="@dimen/status_bar_recents_fading_edge_length"
        android:layout_gravity="bottom|left"
        android:orientation="horizontal"
        android:clipToPadding="false"
        android:clipChildren="false">

        <LinearLayout android:id="@+id/child_container"
            android:layout_width="wrap_content"
            android:layout_height="match_parent"
            android:orientation="horizontal"
            android:clipToPadding="false"
            android:clipChildren="false">

            <LinearLayout android:id="@+id/recents_linear_layout"
                android:layout_width="wrap_content"
                android:layout_height="match_parent"
                android:orientation="horizontal"
                android:clipToPadding="false"
                android:clipChildren="false" />

        <ImageView android:id="@+id/sense_landscape"
        android:gravity="center"
        android:layout_gravity="center"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_marginTop="0.0dip"
        android:src="@drawable/sense_landscape"
        android:visibility="visible" />



        </LinearLayout>


    </com.android.systemui.recent.RecentsHorizontalScrollView>
user809486
  • 888
  • 1
  • 7
  • 15