Tuesday, 15 February 2011

android - Hide a layout when focus on it is lost in XML -



android - Hide a layout when focus on it is lost in XML -

i have next xml file:

<?xml version="1.0" encoding="utf-8"?> <framelayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/framelayout" android:layout_width="match_parent" android:layout_height="match_parent" > <android.support.v4.view.viewpager xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/pager" android:layout_width="match_parent" android:layout_height="match_parent" > </android.support.v4.view.viewpager> <linearlayout android:id="@+id/musiclayout" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_gravity="bottom" android:gravity="center" android:orientation="horizontal" android:padding="10dp" android:focusable="true" android:visibility="visible" > <imageview android:id="@+id/backward" android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@drawable/backward" /> <imageview android:id="@+id/stop" android:layout_width="wrap_content" android:layout_height="wrap_content" android:paddingleft="8dp" android:src="@drawable/stop" /> <imageview android:id="@+id/pauseplay" android:layout_width="wrap_content" android:layout_height="wrap_content" android:paddingleft="8dp" android:src="@drawable/play" /> <imageview android:id="@+id/forward" android:layout_width="wrap_content" android:layout_height="wrap_content" android:paddingleft="8dp" android:paddingright="10dp" android:src="@drawable/forward" /> </linearlayout>

the framelayout actionbar tabs viewpager in above layout. actionbar works perfect. problem want solve lastly linearlayout, media player floating in bottom of screen, needs hidden when press outside linearlayout! have tested onfocuschangelistener in musiclayout , onclick in pageviewer nil happens! doing wrong? edit: in case helps, every tab fragment own layout added viewpager.

i think easiest solution problem add together transparent view matches parent of viewgroup. basically, have viewpager, linearlayout , view @ same level. can register onclicklistener on transparent view , should trick.

layout should simple :

<view android:id="@+id/transparent_view" android:layout_width="match_parent" android:layout_height="match_parent" android:clickable="true"/>

android layout tabs lost-focus

No comments:

Post a Comment