Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <LinearLayout
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:layout_weight="1"
- android:orientation="horizontal">
- <RelativeLayout
- style="@style/AZ.Menu.Icon"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:background="@color/darkorange">
- <ImageView
- android:id="@+id/menu_about"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:layout_centerInParent="true"
- android:src="@drawable/menu_about" />
- <TextView
- style="@style/AZ.Menu.Label"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="@string/menu_about" />
- </RelativeLayout>
- <RelativeLayout
- style="@style/AZ.Menu.Icon"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:background="@color/darkblue">
- <ImageView
- android:id="@+id/menu_settings"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:layout_centerInParent="true"
- android:src="@drawable/menu_settings" />
- <TextView
- style="@style/AZ.Menu.Label"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="@string/menu_settings" />
- </RelativeLayout>
- <ImageView
- style="@style/AZ.Menu.Icon"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:background="@color/grey" />
- </LinearLayout>
- public class MenuItemView extends RelativeLayout {
- private String mLabel;
- private int mLabelRes = 0;
- private int mBackgroundRes = 0;
- private int mIconRes = 0;
- private MenuItemViewBinding mBinding;
- public MenuItemView(Context context, AttributeSet attrs) {
- super(context, attrs);
- getAttributes(context, attrs);
- init(context);
- }
- private void getAttributes(Context context, AttributeSet attrs) {
- TypedArray typedArray = context.getTheme().obtainStyledAttributes(
- attrs,
- R.styleable.MenuItemView,
- 0, 0);
- try {
- mBackgroundRes = typedArray.getResourceId(R.styleable.MenuItemView_backgroundColor, R.color.grey);
- mLabel = typedArray.getString(R.styleable.MenuItemView_label);
- mLabelRes = typedArray.getResourceId(R.styleable.MenuItemView_label, 0);
- mIconRes = typedArray.getResourceId(R.styleable.MenuItemView_icon, 0);
- } finally {
- typedArray.recycle();
- }
- }
- private void init(Context context) {
- mBinding = DataBindingUtil.inflate(LayoutInflater.from(context), R.layout.menu_item_view, (ViewGroup) this.getParent(), true);
- mBinding.conMenuItem.setBackgroundResource(mBackgroundRes);
- mBinding.txtMenuItem.setText(mLabelRes != 0 ? getContext().getString(mLabelRes) : mLabel);
- mBinding.imgMenuItem.setImageResource(mIconRes);
- invalidate();
- requestLayout();
- }}
- <declare-styleable name="MenuItemView">
- <attr name="backgroundColor" format="reference|color" />
- <attr name="label" format="reference|string" />
- <attr name="icon" format="reference" />
- </declare-styleable>
- <layout xmlns:android="http://schemas.android.com/apk/res/android">
- <RelativeLayout
- style="@style/AZ.Menu.Icon"
- android:id="@+id/conMenuItem"
- android:layout_width="match_parent"
- android:layout_height="match_parent">
- <ImageView
- android:id="@+id/imgMenuItem"
- android:layout_width="match_parent"
- android:layout_height="match_parent" />
- <TextView
- android:id="@+id/txtMenuItem"
- style="@style/AZ.Menu.Label"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content" />
- <ProgressBar
- android:id="@+id/pgbMenuItem"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:layout_margin="5dp"
- android:indeterminateTint="@color/nightblue"
- android:indeterminateTintMode="src_atop"
- android:visibility="gone" />
- </RelativeLayout>
- <LinearLayout
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:layout_weight="1"
- android:orientation="horizontal">
- <com.azconception.taxi.view.MenuItemView
- style="@style/AZ.Menu.Icon"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- custom:background="@color/darkblue"
- custom:icon="@drawable/menu_item"
- custom:label="TEST" />
- <com.azconception.taxi.view.MenuItemView
- style="@style/AZ.Menu.Icon"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- custom:background="@color/darkblue"
- custom:icon="@drawable/menu_item"
- custom:label="TEST" />
- <com.azconception.taxi.view.MenuItemView
- style="@style/AZ.Menu.Icon"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- custom:background="@color/darkblue"
- custom:icon="@drawable/menu_item"
- custom:label="TEST" />
- </LinearLayout>
Add Comment
Please, Sign In to add comment