android - How to show the toolbar layout only when a song is played (ListView item is clicked) -
activity_main2.xml
i want show toolbar in following code when listview item clicked. otherwise, remain hidden. if use (view.invisible) in java code layout disappears, yet white space remains in area. want listview occupy area.
<?xml version="1.0" encoding="utf-8" ?> <linearlayout 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:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" tools:context="com.example.ashutosh.music_player.main2activity"> <imageview android:layout_width="match_parent" android:layout_height="wrap_content" android:id="@+id/catv" /> <listview android:id="@+id/track_list_view" android:layout_width="match_parent" android:layout_weight="100" android:layout_height="0dp" android:overscrollheader="@drawable/catv1"/> <android.support.v7.widget.toolbar android:id="@+id/bar_player" android:background="#333333" android:theme="@style/theme.appcompat.dark.darkactionbar" android:layout_width="match_parent" android:layout_height="50dp" app:contentinsetstart="0dp"> <imageview android:id="@+id/selected_track_image" android:layout_width="50dp" android:layout_height="55dp" /> <textview android:id="@+id/selected_track_title" android:paddingleft="8dp" android:layout_width="220dp" android:layout_height="wrap_content" /> <imageview android:id="@+id/forward" android:layout_width="48dp" android:layout_height="48dp" android:layout_marginleft="30dp"/> <imageview android:id="@+id/player_control" android:layout_gravity="right" android:layout_width="@dimen/image_size" android:layout_height="@dimen/image_size" /> </android.support.v7.widget.toolbar> </linearlayout>
try this,this @shijil said
<?xml version="1.0" encoding="utf-8" ?> <linearlayout 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:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" tools:context="com.example.ashutosh.music_player.main2activity"> <imageview android:layout_width="match_parent" android:layout_height="wrap_content" android:id="@+id/catv" /> <listview android:id="@+id/track_list_view" android:layout_width="match_parent" android:layout_weight="100" android:layout_height="0dp" android:overscrollheader="@drawable/catv1"/> <android.support.v7.widget.toolbar android:id="@+id/bar_player" android:background="#333333" android:theme="@style/theme.appcompat.dark.darkactionbar" android:layout_width="match_parent" android:visibility="gone" android:layout_height="50dp" app:contentinsetstart="0dp"> <imageview android:id="@+id/selected_track_image" android:layout_width="50dp" android:layout_height="55dp" /> <textview android:id="@+id/selected_track_title" android:paddingleft="8dp" android:layout_width="220dp" android:layout_height="wrap_content" /> <imageview android:id="@+id/forward" android:layout_width="48dp" android:layout_height="48dp" android:layout_marginleft="30dp"/> <imageview android:id="@+id/player_control" android:layout_gravity="right" android:layout_width="@dimen/image_size" android:layout_height="@dimen/image_size" /> </android.support.v7.widget.toolbar> </linearlayout>
and set programatically
.setvisibility(view.gone); .setvisibility(view.visible);
as needed
Comments
Post a Comment