Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ////////////////////////
- /// values > attrs.xml
- ////////////////////////
- <?xml version="1.0" encoding="utf-8"?>
- <resources>
- <declare-styleable name="MusicGridItem">
- <attr name="image_source" format="reference" />
- <attr name="text" format="string" />
- <attr name="text_color" format="color" />
- <attr name="bar_color" format="color" />
- <attr name="icon_source" format="reference" />
- <attr name="checkbox_color" format="string" />
- <attr name="checkbox_gravity" format="enum">
- <enum name="left" value="0"/>
- <enum name="right" value="1"/>
- </attr>
- <attr name="extend_image" format="boolean" />
- <attr name="android:checkable" />
- <attr name="android:width" />
- <attr name="android:height" />
- </declare-styleable>
- </resources>
- ////////////////////////////////////
- /// src > ... > MusicGridItem.java
- ////////////////////////////////////
- public class MusicGridItem extends View {
- int imageSource;
- String text;
- int textColor;
- int barColor;
- int iconSource;
- int checkboxColor;
- int checkboxGravity;
- boolean isImageExtended;
- boolean isSelectable;
- int width;
- int height;
- public MusicGridItem(Context context, AttributeSet attrs) {
- super(context, attrs);
- TypedArray attr = context.getTheme().obtainStyledAttributes(attrs, android.R.styleable.MusicGridItem, 0, 0);
- try {
- imageSource = attr.getResourceId( R.resources.musicgriditem_image_source, 0);
- } finally {
- attr.recycle();
- }
- }
- }
- ////////////////////////////////////////////
- /// concept layout.xml example intentions
- ////////////////////////////////////////////
- Note: it mimics Google Play Musics "music grid item" on mobile
- <FrameLayout
- android:layout_width="200dp"
- android:layout_height="100dp" >
- <ImageView android:id="@+id/image"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:background="@color/black"
- android:src="@drawable/artistPhotoGeneric" >
- </ImageView>
- <CheckBox
- android:id="@+id/select"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_gravity="right"
- android:layout_margin="10dp"
- android:background="@color/white">
- </CheckBox>
- <LinearLayout
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:layout_gravity="bottom"
- android:orientation="horizontal"
- android:background="@color/black">
- <TextView
- android:id="@+id/description"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_weight="1"
- android:text="Artist_Name"
- android:textAppearance="?android:attr/textAppearanceMedium" >
- </TextView>
- <ImageView
- android:id="@+id/more"
- android:layout_width="24dp"
- android:layout_height="24dp"
- android:src="@drawable/ic_launcher" >
- </ImageView>
- </LinearLayout>
- </FrameLayout>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement