[Android] Audio browser: customize the style of the AudioAlbumsSongsFragment tab widget according to the new design.
Adrien Maglo
git at videolan.org
Mon Nov 25 12:30:02 CET 2013
vlc-ports/android | branch: master | Adrien Maglo <magsoft at videolan.org> | Mon Nov 25 12:29:50 2013 +0100| [46cedb7dd7e581ecfae7aeb2f1edb9870f2ce632] | committer: Adrien Maglo
Audio browser: customize the style of the AudioAlbumsSongsFragment tab widget according to the new design.
> http://git.videolan.org/gitweb.cgi/vlc-ports/android.git/?a=commit;h=46cedb7dd7e581ecfae7aeb2f1edb9870f2ce632
---
vlc-android/res/drawable/tab_indicator.xml | 11 +++++++++
vlc-android/res/drawable/tab_pressed.xml | 26 ++++++++++++++++++++
vlc-android/res/drawable/tab_selected.xml | 21 ++++++++++++++++
vlc-android/res/drawable/tab_unselected.xml | 21 ++++++++++++++++
vlc-android/res/layout/audio_albums_songs.xml | 3 ++-
.../res/layout/audio_browser_tab_layout.xml | 14 +++++++++++
.../vlc/gui/audio/AudioAlbumsSongsFragment.java | 22 +++++++++++++++--
7 files changed, 115 insertions(+), 3 deletions(-)
diff --git a/vlc-android/res/drawable/tab_indicator.xml b/vlc-android/res/drawable/tab_indicator.xml
new file mode 100644
index 0000000..dd89988
--- /dev/null
+++ b/vlc-android/res/drawable/tab_indicator.xml
@@ -0,0 +1,11 @@
+<selector xmlns:android="http://schemas.android.com/apk/res/android">
+
+ <!-- Non focused states -->
+ <item android:drawable="@drawable/tab_unselected" android:state_focused="false" android:state_pressed="false" android:state_selected="false"/>
+ <item android:drawable="@drawable/tab_selected" android:state_focused="false" android:state_pressed="false" android:state_selected="true"/>
+
+ <!-- Pressed -->
+ <item android:drawable="@drawable/tab_pressed" android:state_pressed="true" android:state_selected="true"/>
+ <item android:drawable="@drawable/tab_pressed" android:state_pressed="true"/>
+
+</selector>
diff --git a/vlc-android/res/drawable/tab_pressed.xml b/vlc-android/res/drawable/tab_pressed.xml
new file mode 100644
index 0000000..5fa6760
--- /dev/null
+++ b/vlc-android/res/drawable/tab_pressed.xml
@@ -0,0 +1,26 @@
+<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >
+
+ <item>
+ <shape android:shape="rectangle" >
+ <solid android:color="#FFcccccc" />
+ </shape>
+ </item>
+ <item
+ android:bottom="0dp"
+ android:left="-2dp"
+ android:right="-2dp"
+ android:top="-2dp">
+ <shape android:shape="rectangle" >
+ <padding
+ android:bottom="15dp"
+ android:left="10dp"
+ android:right="10dp"
+ android:top="15dp" />
+
+ <stroke
+ android:width="2dp"
+ android:color="@color/orange" />
+ </shape>
+ </item>
+
+</layer-list>
diff --git a/vlc-android/res/drawable/tab_selected.xml b/vlc-android/res/drawable/tab_selected.xml
new file mode 100644
index 0000000..af121fd
--- /dev/null
+++ b/vlc-android/res/drawable/tab_selected.xml
@@ -0,0 +1,21 @@
+<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >
+
+ <item
+ android:bottom="0dp"
+ android:left="-6dp"
+ android:right="-6dp"
+ android:top="-6dp">
+ <shape android:shape="rectangle" >
+ <padding
+ android:bottom="15dp"
+ android:left="10dp"
+ android:right="10dp"
+ android:top="15dp" />
+
+ <stroke
+ android:width="6dp"
+ android:color="@color/orange" />
+ </shape>
+ </item>
+
+</layer-list>
diff --git a/vlc-android/res/drawable/tab_unselected.xml b/vlc-android/res/drawable/tab_unselected.xml
new file mode 100644
index 0000000..5a42361
--- /dev/null
+++ b/vlc-android/res/drawable/tab_unselected.xml
@@ -0,0 +1,21 @@
+<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >
+
+ <item
+ android:bottom="0dp"
+ android:left="-2dp"
+ android:right="-2dp"
+ android:top="-2dp">
+ <shape android:shape="rectangle" >
+ <padding
+ android:bottom="15dp"
+ android:left="10dp"
+ android:right="10dp"
+ android:top="15dp" />
+
+ <stroke
+ android:width="2dp"
+ android:color="@color/orange" />
+ </shape>
+ </item>
+
+</layer-list>
diff --git a/vlc-android/res/layout/audio_albums_songs.xml b/vlc-android/res/layout/audio_albums_songs.xml
index 869f76a..00c4d89 100644
--- a/vlc-android/res/layout/audio_albums_songs.xml
+++ b/vlc-android/res/layout/audio_albums_songs.xml
@@ -13,7 +13,8 @@
<TabWidget
android:id="@android:id/tabs"
android:layout_width="match_parent"
- android:layout_height="wrap_content" >
+ android:layout_height="wrap_content"
+ android:background="?attr/background_menu">
</TabWidget>
<FrameLayout
diff --git a/vlc-android/res/layout/audio_browser_tab_layout.xml b/vlc-android/res/layout/audio_browser_tab_layout.xml
new file mode 100644
index 0000000..bc5b5d0
--- /dev/null
+++ b/vlc-android/res/layout/audio_browser_tab_layout.xml
@@ -0,0 +1,14 @@
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_width="fill_parent"
+ android:layout_height="fill_parent"
+ android:background="@drawable/tab_indicator"
+ android:orientation="vertical" >
+
+ <TextView
+ android:id="@+id/textView"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_gravity="center_vertical|center_horizontal"
+ android:textAllCaps="true" />
+
+</LinearLayout>
diff --git a/vlc-android/src/org/videolan/vlc/gui/audio/AudioAlbumsSongsFragment.java b/vlc-android/src/org/videolan/vlc/gui/audio/AudioAlbumsSongsFragment.java
index 65b7de2..350d486 100644
--- a/vlc-android/src/org/videolan/vlc/gui/audio/AudioAlbumsSongsFragment.java
+++ b/vlc-android/src/org/videolan/vlc/gui/audio/AudioAlbumsSongsFragment.java
@@ -28,6 +28,7 @@ import org.videolan.vlc.R;
import org.videolan.vlc.Util;
import org.videolan.vlc.gui.MainActivity;
+import android.content.Context;
import android.os.Bundle;
import android.view.ContextMenu;
import android.view.ContextMenu.ContextMenuInfo;
@@ -40,6 +41,9 @@ import android.widget.AdapterView.OnItemClickListener;
import android.widget.AdapterView;
import android.widget.ListView;
import android.widget.TabHost;
+import android.widget.TabHost.TabSpec;
+import android.widget.TextView;
+
import com.actionbarsherlock.app.SherlockFragment;
public class AudioAlbumsSongsFragment extends SherlockFragment {
@@ -96,9 +100,23 @@ public class AudioAlbumsSongsFragment extends SherlockFragment {
tabHost.setup();
- tabHost.addTab(tabHost.newTabSpec("albums").setIndicator("Albums").setContent(R.id.albums));
- tabHost.addTab(tabHost.newTabSpec("songs").setIndicator("Songs").setContent(R.id.songs));
+ addNewTab(tabHost, "albums", "Albums", R.id.albums);
+ addNewTab(tabHost, "songs", "Songs", R.id.songs);
+
+ return v;
+ }
+
+ private void addNewTab(TabHost tabHost, String tag, String title, int contentID) {
+ TabSpec tabSpec = tabHost.newTabSpec(tag);
+ tabSpec.setIndicator(getNewTabIndicator(tabHost.getContext(), title));
+ tabSpec.setContent(contentID);
+ tabHost.addTab(tabSpec);
+ }
+ private View getNewTabIndicator(Context context, String title) {
+ View v = LayoutInflater.from(context).inflate(R.layout.audio_browser_tab_layout, null);
+ TextView tv = (TextView) v.findViewById(R.id.textView);
+ tv.setText(title);
return v;
}
More information about the Android
mailing list