android.widget.ImageButton# setPadding ( ) 源码实例Demo

下面列出了android.widget.ImageButton# setPadding ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。


/**
 * <ImageButton
 android:id="@+id/ancp_poi_list_drap_bar"
 android:layout_width="match_parent"
 android:layout_height="wrap_content"
 android:background="@color/new_line_border"
 android:src="@drawable/bnav_poi_list_drag"
 android:paddingBottom="10dp"
 android:paddingTop="10dp"
 />
 */
private void init(){
    DisplayMetrics metrics=getContext().getResources().getDisplayMetrics();
    density=metrics.density;
    sHeight=metrics.heightPixels;
    minHeight=dp2px(50);
    Log.i(TAG,"sHeight="+sHeight+",minHeight="+50);
    drawBar=new ImageButton(getContext());
    LayoutParams layoutParams=new LayoutParams(LayoutParams.MATCH_PARENT,LayoutParams.WRAP_CONTENT);
    drawBar.setBackgroundResource(R.color.base_blue_translucent);
    drawBar.setImageResource(R.drawable.bnav_poi_list_drag);
    drawBar.setPadding(0, dp2px(10), 0, dp2px(10));
    addView(drawBar, 0, layoutParams);

    drawBar.setOnTouchListener(drawTouchListener);
}
 
源代码2 项目: RedReader   文件: ExoPlayerWrapperView.java

private static ImageButton createButton(
		@NonNull final Context context,
		@NonNull final ViewGroup root,
		@DrawableRes final int image,
		@NonNull final OnClickListener clickListener) {

	final ImageButton ib = (ImageButton)LayoutInflater.from(context).inflate(R.layout.flat_image_button, root, false);

	final int buttonPadding = General.dpToPixels(context, 14);
	ib.setPadding(buttonPadding, buttonPadding, buttonPadding, buttonPadding);

	ib.setImageResource(image);

	ib.setOnClickListener(clickListener);

	return ib;
}
 
源代码3 项目: RedReader   文件: ImageViewActivity.java

@Nullable
private ImageButton addFloatingToolbarButton(
		final int drawable,
		@NonNull final View.OnClickListener listener) {

	if(mFloatingToolbar == null) {
		return null;
	}

	mFloatingToolbar.setVisibility(View.VISIBLE);

	final ImageButton ib = (ImageButton) LayoutInflater.from(this).inflate(
			R.layout.flat_image_button,
			mFloatingToolbar,
			false);

	final int buttonPadding = General.dpToPixels(this, 10);
	ib.setPadding(buttonPadding, buttonPadding, buttonPadding, buttonPadding);
	ib.setImageResource(drawable);

	ib.setOnClickListener(listener);

	mFloatingToolbar.addView(ib);

	return ib;
}
 

public void initUI() {

        LinearLayout parent = EditManager.INSTANCE.getToolsLayout();
        Context context = parent.getContext();
//        IEditableLayer editLayer = EditManager.INSTANCE.getEditLayer();
        int padding = 2;

        selectAllButton = new ImageButton(context);
        selectAllButton.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
        selectAllButton.setBackground(Compat.getDrawable(context, R.drawable.ic_editing_select_all_24dp));
        selectAllButton.setPadding(0, padding, 0, padding);
        selectAllButton.setOnClickListener(this);
        selectAllButton.setOnTouchListener(this);
        parent.addView(selectAllButton);
    }
 
源代码5 项目: delion   文件: InfoBarLayout.java

/**
 * Constructs a layout for the specified infobar. After calling this, be sure to set the
 * message, the buttons, and/or the custom content using setMessage(), setButtons(), and
 * setCustomContent().
 *
 * @param context The context used to render.
 * @param infoBarView InfoBarView that listens to events.
 * @param iconResourceId ID of the icon to use for the infobar.
 * @param iconBitmap Bitmap for the icon to use, if the resource ID wasn't passed through.
 * @param message The message to show in the infobar.
 */
public InfoBarLayout(Context context, InfoBarView infoBarView, int iconResourceId,
        Bitmap iconBitmap, CharSequence message) {
    super(context);
    mControlLayouts = new ArrayList<InfoBarControlLayout>();

    mInfoBarView = infoBarView;

    // Cache resource values.
    Resources res = getResources();
    mSmallIconSize = res.getDimensionPixelSize(R.dimen.infobar_small_icon_size);
    mSmallIconMargin = res.getDimensionPixelSize(R.dimen.infobar_small_icon_margin);
    mBigIconSize = res.getDimensionPixelSize(R.dimen.infobar_big_icon_size);
    mBigIconMargin = res.getDimensionPixelSize(R.dimen.infobar_big_icon_margin);
    mMarginAboveButtonGroup =
            res.getDimensionPixelSize(R.dimen.infobar_margin_above_button_row);
    mMarginAboveControlGroups =
            res.getDimensionPixelSize(R.dimen.infobar_margin_above_control_groups);
    mPadding = res.getDimensionPixelOffset(R.dimen.infobar_padding);
    mMinWidth = res.getDimensionPixelSize(R.dimen.infobar_min_width);
    mAccentColor = ApiCompatibilityUtils.getColor(res, R.color.infobar_accent_blue);

    // Set up the close button. Apply padding so it has a big touch target.
    mCloseButton = new ImageButton(context);
    mCloseButton.setId(R.id.infobar_close_button);
    mCloseButton.setImageResource(R.drawable.btn_close);
    TypedArray a = getContext().obtainStyledAttributes(
            new int [] {R.attr.selectableItemBackground});
    Drawable closeButtonBackground = a.getDrawable(0);
    a.recycle();
    mCloseButton.setBackground(closeButtonBackground);
    mCloseButton.setPadding(mPadding, mPadding, mPadding, mPadding);
    mCloseButton.setOnClickListener(this);
    mCloseButton.setContentDescription(res.getString(R.string.infobar_close));
    mCloseButton.setLayoutParams(new LayoutParams(0, -mPadding, -mPadding, -mPadding));

    // Set up the icon.
    if (iconResourceId != 0 || iconBitmap != null) {
        mIconView = new ImageView(context);
        if (iconResourceId != 0) {
            mIconView.setImageResource(iconResourceId);
        } else if (iconBitmap != null) {
            mIconView.setImageBitmap(iconBitmap);
        }
        mIconView.setLayoutParams(new LayoutParams(0, 0, mSmallIconMargin, 0));
        mIconView.getLayoutParams().width = mSmallIconSize;
        mIconView.getLayoutParams().height = mSmallIconSize;
        mIconView.setFocusable(false);
    }

    // Set up the message view.
    mMessageMainText = message;
    mMessageLayout = new InfoBarControlLayout(context);
    mMessageTextView = mMessageLayout.addMainMessage(prepareMainMessageString());
}
 
源代码6 项目: AndroidChromium   文件: InfoBarLayout.java

/**
 * Constructs a layout for the specified infobar. After calling this, be sure to set the
 * message, the buttons, and/or the custom content using setMessage(), setButtons(), and
 * setCustomContent().
 *
 * @param context The context used to render.
 * @param infoBarView InfoBarView that listens to events.
 * @param iconResourceId ID of the icon to use for the infobar.
 * @param iconBitmap Bitmap for the icon to use, if the resource ID wasn't passed through.
 * @param message The message to show in the infobar.
 */
public InfoBarLayout(Context context, InfoBarView infoBarView, int iconResourceId,
        Bitmap iconBitmap, CharSequence message) {
    super(context);
    mControlLayouts = new ArrayList<InfoBarControlLayout>();

    mInfoBarView = infoBarView;

    // Cache resource values.
    Resources res = getResources();
    mSmallIconSize = res.getDimensionPixelSize(R.dimen.infobar_small_icon_size);
    mSmallIconMargin = res.getDimensionPixelSize(R.dimen.infobar_small_icon_margin);
    mBigIconSize = res.getDimensionPixelSize(R.dimen.infobar_big_icon_size);
    mBigIconMargin = res.getDimensionPixelSize(R.dimen.infobar_big_icon_margin);
    mMarginAboveButtonGroup =
            res.getDimensionPixelSize(R.dimen.infobar_margin_above_button_row);
    mMarginAboveControlGroups =
            res.getDimensionPixelSize(R.dimen.infobar_margin_above_control_groups);
    mPadding = res.getDimensionPixelOffset(R.dimen.infobar_padding);
    mMinWidth = res.getDimensionPixelSize(R.dimen.infobar_min_width);
    mAccentColor = ApiCompatibilityUtils.getColor(res, R.color.infobar_accent_blue);

    // Set up the close button. Apply padding so it has a big touch target.
    mCloseButton = new ImageButton(context);
    mCloseButton.setId(R.id.infobar_close_button);
    mCloseButton.setImageResource(R.drawable.btn_close);
    TypedArray a = getContext().obtainStyledAttributes(
            new int [] {R.attr.selectableItemBackground});
    Drawable closeButtonBackground = a.getDrawable(0);
    a.recycle();
    mCloseButton.setBackground(closeButtonBackground);
    mCloseButton.setPadding(mPadding, mPadding, mPadding, mPadding);
    mCloseButton.setOnClickListener(this);
    mCloseButton.setContentDescription(res.getString(R.string.infobar_close));
    mCloseButton.setLayoutParams(new LayoutParams(0, -mPadding, -mPadding, -mPadding));

    // Set up the icon.
    if (iconResourceId != 0 || iconBitmap != null) {
        mIconView = new ImageView(context);
        if (iconResourceId != 0) {
            mIconView.setImageResource(iconResourceId);
        } else if (iconBitmap != null) {
            mIconView.setImageBitmap(iconBitmap);
        }
        mIconView.setLayoutParams(new LayoutParams(0, 0, mSmallIconMargin, 0));
        mIconView.getLayoutParams().width = mSmallIconSize;
        mIconView.getLayoutParams().height = mSmallIconSize;
        mIconView.setFocusable(false);
    }

    // Set up the message view.
    mMessageMainText = message;
    mMessageLayout = new InfoBarControlLayout(context);
    mMessageTextView = mMessageLayout.addMainMessage(prepareMainMessageString());
}
 

/**
     * Creates a textView with the given string, and adds it to the item list
     * @param text String to add to the list
     */
    private void addUrlView(String text){
        final String rowName = text;
        // Create a new Layout to hold items
        final LinearLayout itemRow = new LinearLayout(getContext());
        itemRow.setLayoutParams(new LinearLayout.LayoutParams(
                LinearLayout.LayoutParams.MATCH_PARENT,
                LinearLayout.LayoutParams.WRAP_CONTENT,
                LinearLayout.HORIZONTAL));
        itemRow.setGravity(Gravity.CENTER);
//        itemRow.setPadding(0,48,0, 48);
//        itemRow.setBackground(getResources().getDrawable(R.drawable.delete_bg));


        ImageButton deleteButton = new ImageButton(getContext());
        deleteButton.setImageResource(R.drawable.delete_forever);
        deleteButton.setBackground(null);
        deleteButton.setVisibility(View.GONE);
        deleteButton.setPadding(48,48,48, 48);
        deleteButton.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                if(removeStringFromSet(text)){
                    labelHolder = (LinearLayout)ViewAnimation.fadeOutAndRemove(itemRow, labelHolder, 250);
                }
            }
        });

        // Create checkbox
        CheckBox check = new CheckBox(getContext());
        check.setPadding(16,0,64,0);
        check.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(CompoundButton compoundButton, boolean b) {
//                setDeleteSelected();
            }
        });

        // Create text
        TextView nameText = new TextView(getContext());
        nameText.setText(text);
        LinearLayout.LayoutParams textLayout = new LinearLayout.LayoutParams(
                LinearLayout.LayoutParams.MATCH_PARENT,
                LinearLayout.LayoutParams.WRAP_CONTENT);
        textLayout.setMargins(16, 16, 16, 16);
        textLayout.gravity = Gravity.CENTER;
        nameText.setLayoutParams(textLayout);
        nameText.setPadding(32,32,32, 32);

        nameText.setTextAppearance(getContext(), R.style.textAppearanceSubtitle1);

        // Add everything
        itemRow.addView(deleteButton);
//        itemRow.addView(check);
        itemRow.addView(nameText);
        ViewAnimation.setSlideInFromRightAnimation(itemRow, 250);
        labelHolder.addView(itemRow);
    }
 

private void addRowForAnswer(final Context context, final TableLayout tableLayout, final DecisionTree.Question question, final DecisionTree.BaseButton answer) {
    final TableRow row = new TableRow(context);
    final TableLayout.LayoutParams params = new TableLayout.LayoutParams(TableLayout.LayoutParams.MATCH_PARENT,
            TableLayout.LayoutParams.WRAP_CONTENT);
    params.setMargins(0, UiUtils.getPxForDpResource(context, R.dimen.standard_large_margin), 0, 0);
    tableLayout.addView(row, params);


    final LinearLayout layoutVertical = new LinearLayout(context);
    layoutVertical.setOrientation(LinearLayout.VERTICAL);

    final TextView textViewAnswer = new AppCompatTextView(context);
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
        textViewAnswer.setTextAppearance(R.style.TextAppearance_AppCompat_Subhead);
    } else {
        //noinspection deprecation
        textViewAnswer.setTextAppearance(context, R.style.TextAppearance_AppCompat_Subhead);
    }
    textViewAnswer.setText(answer.getText());
    layoutVertical.addView(textViewAnswer,
            new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT));

    final LinearLayout layoutHorizontal = new LinearLayout(context);
    layoutHorizontal.setOrientation(LinearLayout.HORIZONTAL);
    final LinearLayout.LayoutParams paramsHorizontal = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT,
            LinearLayout.LayoutParams.WRAP_CONTENT);
    paramsHorizontal.setMargins(0, UiUtils.getPxForDpResource(context, R.dimen.standard_margin), 0, 0);
    layoutVertical.addView(layoutHorizontal, paramsHorizontal);

    final BitmapDrawable icon = getIcon(context, answer);
    final ImageView imageIcon = new ImageView(context);
    imageIcon.setImageDrawable(icon);
    layoutHorizontal.addView(imageIcon);

    final LinearLayout.LayoutParams paramsImage = new LinearLayout.LayoutParams(
            LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT);

    // TODO: Use a custom FlowTable class to avoid items going off the right edge of the screen
    // when there are too many.
    final Singleton singleton = getSingleton();
    for (int i = 0; i < answer.getExamplesCount(); i++) {

        final String iconName = answer.getExampleIconName(question.getId(), i);
        final BitmapDrawable iconExample = singleton.getIconDrawable(context, iconName);
        final ImageButton imageExample = new ImageButton(context);
        //Remove the space between the image and the outside of the button:
        imageExample.setPadding(0, 0, 0, 0);
        imageExample.setImageDrawable(iconExample);

        //Needed to make the image expand as a transition into the SubjectViewerActivity,
        //which uses the same name in fragment_subject.xml
        ViewCompat.setTransitionName(imageExample, getString(R.string.transition_subject_image));

        //This requires API level 17: paramsImage.setMarginStart(getPxForDp(activity, MARGIN_MEDIUM_DP));
        //imageExample.setLayoutParams(paramsImage);
        MarginLayoutParamsCompat.setMarginStart(paramsImage, UiUtils.getPxForDpResource(context, R.dimen.standard_large_margin));

        final int answerIndex = i;
        imageExample.setOnClickListener(new View.OnClickListener() {
            public void onClick(final View v) {
                // Perform action on click
                onExampleImageClicked(v, answer, answerIndex);
            }
        });

        layoutHorizontal.addView(imageExample, paramsImage);
    }

    row.addView(layoutVertical,
            new TableRow.LayoutParams(TableRow.LayoutParams.MATCH_PARENT, TableRow.LayoutParams.WRAP_CONTENT));
}
 

public void initUI() {
    LinearLayout parent = EditManager.INSTANCE.getToolsLayout();
    parent.removeAllViews();

    Context context = parent.getContext();
    IEditableLayer editLayer = EditManager.INSTANCE.getEditLayer();
    int padding = 2;

    if (editLayer != null) {
        gpsStreamButton = new ImageButton(context);
        gpsStreamButton.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
        gpsStreamButton.setBackground(Compat.getDrawable(context, R.drawable.ic_editing_add_point_gps_off_24dp));
        gpsStreamButton.setPadding(0, padding, 0, padding);
        gpsStreamButton.setOnTouchListener(this);
        gpsStreamButton.setOnLongClickListener(this);
        gpsStreamButton.setOnClickListener(this);
        parent.addView(gpsStreamButton);

        addVertexButton = new ImageButton(context);
        addVertexButton.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
        addVertexButton.setBackground(Compat.getDrawable(context, R.drawable.ic_editing_add_point_center_24dp));
        addVertexButton.setPadding(0, padding, 0, padding);
        addVertexButton.setOnTouchListener(this);
        addVertexButton.setOnClickListener(this);
        parent.addView(addVertexButton);

        addVertexByTapButton = new ImageButton(context);
        addVertexByTapButton.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT,
                LayoutParams.WRAP_CONTENT));
        addVertexByTapButton.setBackground(Compat.getDrawable(context, R.drawable.ic_editing_add_point_tap_off_24dp));
        addVertexByTapButton.setPadding(0, padding, 0, padding);
        addVertexByTapButton.setOnTouchListener(this);
        addVertexByTapButton.setOnClickListener(this);
        parent.addView(addVertexByTapButton);

        undoButton = new ImageButton(context);
        undoButton.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
        undoButton.setBackground(Compat.getDrawable(context, R.drawable.ic_editing_undo_24dp));
        undoButton.setPadding(0, padding, 0, padding);
        undoButton.setOnTouchListener(this);
        undoButton.setOnClickListener(this);
        parent.addView(undoButton);

        commitButton = new ImageButton(context);
        commitButton.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
        commitButton.setBackground(Compat.getDrawable(context, R.drawable.ic_editing_commit_24dp));
        commitButton.setPadding(0, padding, 0, padding);
        commitButton.setOnTouchListener(this);
        commitButton.setOnClickListener(this);
        commitButton.setVisibility(View.GONE);
        parent.addView(commitButton);
    }
}
 

public void initUI() {
        LinearLayout parent = EditManager.INSTANCE.getToolsLayout();
        parent.removeAllViews();

        Context context = parent.getContext();
        IEditableLayer editLayer = EditManager.INSTANCE.getEditLayer();
        int padding = 2;

        if (editLayer != null) {
            deleteFeatureButton = new ImageButton(context);
            deleteFeatureButton.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT,
                    LayoutParams.WRAP_CONTENT));
            deleteFeatureButton.setBackground(Compat.getDrawable(context, R.drawable.ic_editing_delete_point_feature_24dp));
            deleteFeatureButton.setPadding(0, padding, 0, padding);
            deleteFeatureButton.setOnTouchListener(this);
            deleteFeatureButton.setOnClickListener(this);
            parent.addView(deleteFeatureButton);

//            copyFeatureButton = new ImageButton(context);
//            copyFeatureButton.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT,
//                    LayoutParams.WRAP_CONTENT));
//            copyFeatureButton.setBackground(Compat.getDrawable(context, R.drawable.ic_editing_copy_geoms_24dp));
//            copyFeatureButton.setPadding(0, padding, 0, padding);
//            copyFeatureButton.setOnTouchListener(this);
//            copyFeatureButton.setOnClickListener(this);
//            parent.addView(copyFeatureButton);

            editAttributesButton = new ImageButton(context);
            editAttributesButton.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT,
                    LayoutParams.WRAP_CONTENT));
            editAttributesButton.setBackground(Compat.getDrawable(context, R.drawable.ic_editing_view_attributes_24dp));
            editAttributesButton.setPadding(0, padding, 0, padding);
            editAttributesButton.setOnTouchListener(this);
            editAttributesButton.setOnClickListener(this);
            parent.addView(editAttributesButton);

            undoButton = new ImageButton(context);
            undoButton.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
            undoButton.setBackground(Compat.getDrawable(context, R.drawable.ic_editing_undo_24dp));
            undoButton.setPadding(0, padding, 0, padding);
            undoButton.setOnTouchListener(this);
            undoButton.setOnClickListener(this);
            parent.addView(undoButton);

            commitButton = new ImageButton(context);
            commitButton.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
            commitButton.setBackground(Compat.getDrawable(context, R.drawable.ic_editing_commit_24dp));
            commitButton.setPadding(0, padding, 0, padding);
            commitButton.setOnTouchListener(this);
            commitButton.setOnClickListener(this);
            parent.addView(commitButton);
            commitButton.setVisibility(View.GONE);
        }
    }
 

public void initUI() {
    LinearLayout parent = EditManager.INSTANCE.getToolsLayout();
    parent.removeAllViews();

    Context context = parent.getContext();
    IEditableLayer editLayer = EditManager.INSTANCE.getEditLayer();
    int padding = 2;

    if (editLayer != null) {
        gpsStreamButton = new ImageButton(context);
        gpsStreamButton.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
        gpsStreamButton.setBackground(Compat.getDrawable(context, R.drawable.ic_editing_gps_stream_24dp));
        gpsStreamButton.setPadding(0, padding, 0, padding);
        gpsStreamButton.setOnTouchListener(this);
        gpsStreamButton.setOnLongClickListener(this);
        gpsStreamButton.setOnClickListener(this);
        parent.addView(gpsStreamButton);

        addVertexButton = new ImageButton(context);
        addVertexButton.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
        addVertexButton.setBackground(Compat.getDrawable(context, R.drawable.ic_editing_add_vertex_24dp));
        addVertexButton.setPadding(0, padding, 0, padding);
        addVertexButton.setOnTouchListener(this);
        addVertexButton.setOnClickListener(this);
        parent.addView(addVertexButton);

        addVertexByTapButton = new ImageButton(context);
        addVertexByTapButton.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT,
                LayoutParams.WRAP_CONTENT));
        addVertexByTapButton.setBackground(Compat.getDrawable(context, R.drawable.ic_editing_add_vertex_tap_24dp));
        addVertexByTapButton.setPadding(0, padding, 0, padding);
        addVertexByTapButton.setOnTouchListener(this);
        addVertexByTapButton.setOnClickListener(this);
        parent.addView(addVertexByTapButton);

        undoButton = new ImageButton(context);
        undoButton.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
        undoButton.setBackground(Compat.getDrawable(context, R.drawable.ic_editing_undo_24dp));
        undoButton.setPadding(0, padding, 0, padding);
        undoButton.setOnTouchListener(this);
        undoButton.setOnClickListener(this);
        parent.addView(undoButton);

        commitButton = new ImageButton(context);
        commitButton.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
        commitButton.setBackground(Compat.getDrawable(context, R.drawable.ic_editing_commit_24dp));
        commitButton.setPadding(0, padding, 0, padding);
        commitButton.setOnTouchListener(this);
        commitButton.setOnClickListener(this);
        commitButton.setVisibility(View.GONE);
        parent.addView(commitButton);
    }
}
 

public void initUI() {

        LinearLayout parent = EditManager.INSTANCE.getToolsLayout();
        Context context = parent.getContext();
        IEditableLayer editLayer = EditManager.INSTANCE.getEditLayer();
        int padding = 2;

        if (editLayer != null) {
            createFeatureButton = new ImageButton(context);
            createFeatureButton.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT,
                    LayoutParams.WRAP_CONTENT));
            createFeatureButton.setBackground(Compat.getDrawable(context, R.drawable.ic_editing_add_point_24dp));
            createFeatureButton.setPadding(0, padding, 0, padding);
            createFeatureButton.setOnClickListener(this);
            createFeatureButton.setOnTouchListener(this);
            parent.addView(createFeatureButton);

            selectEditableButton = new ImageButton(context);
            selectEditableButton.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT,
                    LayoutParams.WRAP_CONTENT));
            selectEditableButton.setBackground(Compat.getDrawable(context, R.drawable.ic_editing_select_editable_24dp));
            selectEditableButton.setPadding(0, padding, 0, padding);
            selectEditableButton.setOnClickListener(this);
            selectEditableButton.setOnTouchListener(this);
            parent.addView(selectEditableButton);
        }

        selectAllButton = new ImageButton(context);
        selectAllButton.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
        Tool activeTool = EditManager.INSTANCE.getActiveTool();
        if (activeTool instanceof InfoTool) {
            selectAllButton.setBackground(Compat.getDrawable(context, R.drawable.ic_editing_select_all_active_24dp));
        } else {
            selectAllButton.setBackground(Compat.getDrawable(context, R.drawable.ic_editing_select_all_24dp));
        }
        selectAllButton.setPadding(0, padding, 0, padding);
        selectAllButton.setOnClickListener(this);
        selectAllButton.setOnTouchListener(this);
        parent.addView(selectAllButton);

        if (editLayer != null) {
            undoButton = new ImageButton(context);
            undoButton.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
            undoButton.setBackground(Compat.getDrawable(context, R.drawable.ic_editing_undo_24dp));
            undoButton.setPadding(0, padding, 0, padding);
            undoButton.setOnTouchListener(this);
            undoButton.setOnClickListener(this);
            parent.addView(undoButton);
            undoButton.setVisibility(View.GONE);

            commitButton = new ImageButton(context);
            commitButton.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
            commitButton.setBackground(Compat.getDrawable(context, R.drawable.ic_editing_commit_24dp));
            commitButton.setPadding(0, padding, 0, padding);
            commitButton.setOnTouchListener(this);
            commitButton.setOnClickListener(this);
            parent.addView(commitButton);
            commitButton.setVisibility(View.GONE);
        }
    }
 

public void initUI() {
        LinearLayout parent = EditManager.INSTANCE.getToolsLayout();
        parent.removeAllViews();

        Context context = parent.getContext();
        IEditableLayer editLayer = EditManager.INSTANCE.getEditLayer();
        int padding = 2;

        if (editLayer != null) {
            deleteFeatureButton = new ImageButton(context);
            deleteFeatureButton.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT,
                    LayoutParams.WRAP_CONTENT));
            deleteFeatureButton.setBackground(Compat.getDrawable(context, R.drawable.ic_editing_delete_line_feature_24dp));
            deleteFeatureButton.setPadding(0, padding, 0, padding);
            deleteFeatureButton.setOnTouchListener(this);
            deleteFeatureButton.setOnClickListener(this);
            parent.addView(deleteFeatureButton);

//            copyFeatureButton = new ImageButton(context);
//            copyFeatureButton.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT,
//                    LayoutParams.WRAP_CONTENT));
//            copyFeatureButton.setBackground(context.getDrawable(R.drawable.editing_copy_geoms));
//            copyFeatureButton.setPadding(0, padding, 0, padding);
//            copyFeatureButton.setOnTouchListener(this);
//            copyFeatureButton.setOnClickListener(this);
//            parent.addView(copyFeatureButton);

            continueLineFeatureButton = new ImageButton(context);
            continueLineFeatureButton.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT,
                    LayoutParams.WRAP_CONTENT));
            continueLineFeatureButton.setBackground(Compat.getDrawable(context, R.drawable.ic_editing_continue_line_24dp));
            continueLineFeatureButton.setPadding(0, padding, 0, padding);
            continueLineFeatureButton.setOnClickListener(this);
            continueLineFeatureButton.setOnTouchListener(this);
            parent.addView(continueLineFeatureButton);

            editAttributesButton = new ImageButton(context);
            editAttributesButton.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT,
                    LayoutParams.WRAP_CONTENT));
            editAttributesButton.setBackground(Compat.getDrawable(context, R.drawable.ic_editing_view_attributes_24dp));
            editAttributesButton.setPadding(0, padding, 0, padding);
            editAttributesButton.setOnTouchListener(this);
            editAttributesButton.setOnClickListener(this);
            parent.addView(editAttributesButton);

            undoButton = new ImageButton(context);
            undoButton.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
            undoButton.setBackground(Compat.getDrawable(context, R.drawable.ic_editing_undo_24dp));
            undoButton.setPadding(0, padding, 0, padding);
            undoButton.setOnTouchListener(this);
            undoButton.setOnClickListener(this);
            parent.addView(undoButton);

            commitButton = new ImageButton(context);
            commitButton.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
            commitButton.setBackground(Compat.getDrawable(context, R.drawable.ic_editing_commit_24dp));
            commitButton.setPadding(0, padding, 0, padding);
            commitButton.setOnTouchListener(this);
            commitButton.setOnClickListener(this);
            parent.addView(commitButton);
            commitButton.setVisibility(View.GONE);
        }
    }
 

public void initUI() {

        LinearLayout parent = EditManager.INSTANCE.getToolsLayout();
        Context context = parent.getContext();
        IEditableLayer editLayer = EditManager.INSTANCE.getEditLayer();
        int padding = 2;

        if (editLayer != null) {
            cutButton = new ImageButton(context);
            cutButton.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
            cutButton.setBackground(Compat.getDrawable(context, R.drawable.ic_editing_cut_24dp));
            cutButton.setPadding(0, padding, 0, padding);
            cutButton.setOnClickListener(this);
            cutButton.setOnTouchListener(this);
            parent.addView(cutButton);

            extendButton = new ImageButton(context);
            extendButton.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
            extendButton.setBackground(Compat.getDrawable(context, R.drawable.ic_editing_extend_24dp));
            extendButton.setPadding(0, padding, 0, padding);
            extendButton.setOnClickListener(this);
            extendButton.setOnTouchListener(this);
            parent.addView(extendButton);

            createFeatureButton = new ImageButton(context);
            createFeatureButton.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT,
                    LayoutParams.WRAP_CONTENT));
            createFeatureButton.setBackground(Compat.getDrawable(context, R.drawable.ic_editing_create_polygon_24dp));
            createFeatureButton.setPadding(0, padding, 0, padding);
            createFeatureButton.setOnClickListener(this);
            createFeatureButton.setOnTouchListener(this);
            parent.addView(createFeatureButton);

            selectEditableButton = new ImageButton(context);
            selectEditableButton.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT,
                    LayoutParams.WRAP_CONTENT));
            selectEditableButton.setBackground(Compat.getDrawable(context, R.drawable.ic_editing_select_editable_24dp));
            selectEditableButton.setPadding(0, padding, 0, padding);
            selectEditableButton.setOnClickListener(this);
            selectEditableButton.setOnTouchListener(this);
            parent.addView(selectEditableButton);
        }

        selectAllButton = new ImageButton(context);
        selectAllButton.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
        Tool activeTool = EditManager.INSTANCE.getActiveTool();
        if (activeTool instanceof InfoTool) {
            selectAllButton.setBackground(Compat.getDrawable(context, R.drawable.ic_editing_select_all_active_24dp));
        } else {
            selectAllButton.setBackground(Compat.getDrawable(context, R.drawable.ic_editing_select_all_24dp));
        }
        selectAllButton.setPadding(0, padding, 0, padding);
        selectAllButton.setOnClickListener(this);
        selectAllButton.setOnTouchListener(this);
        parent.addView(selectAllButton);

        if (editLayer != null) {
            undoButton = new ImageButton(context);
            undoButton.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
            undoButton.setBackground(Compat.getDrawable(context, R.drawable.ic_editing_undo_24dp));
            undoButton.setPadding(0, padding, 0, padding);
            undoButton.setOnTouchListener(this);
            undoButton.setOnClickListener(this);
            parent.addView(undoButton);
            undoButton.setVisibility(View.GONE);

            commitButton = new ImageButton(context);
            commitButton.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
            commitButton.setBackground(Compat.getDrawable(context, R.drawable.ic_editing_commit_24dp));
            commitButton.setPadding(0, padding, 0, padding);
            commitButton.setOnTouchListener(this);
            commitButton.setOnClickListener(this);
            parent.addView(commitButton);
            commitButton.setVisibility(View.GONE);
        }
    }
 

public void initUI() {
    LinearLayout parent = EditManager.INSTANCE.getToolsLayout();
    parent.removeAllViews();

    Context context = parent.getContext();
    IEditableLayer editLayer = EditManager.INSTANCE.getEditLayer();
    int padding = 2;

    if (editLayer != null) {
        gpsStreamButton = new ImageButton(context);
        gpsStreamButton.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
        gpsStreamButton.setBackground(Compat.getDrawable(context, R.drawable.ic_editing_gps_stream_24dp));
        gpsStreamButton.setPadding(0, padding, 0, padding);
        gpsStreamButton.setOnTouchListener(this);
        gpsStreamButton.setOnLongClickListener(this);
        gpsStreamButton.setOnClickListener(this);
        parent.addView(gpsStreamButton);

        addVertexButton = new ImageButton(context);
        addVertexButton.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
        addVertexButton.setBackground(Compat.getDrawable(context, R.drawable.ic_editing_add_vertex_24dp));
        addVertexButton.setPadding(0, padding, 0, padding);
        addVertexButton.setOnTouchListener(this);
        addVertexButton.setOnClickListener(this);
        parent.addView(addVertexButton);

        addVertexByTapButton = new ImageButton(context);
        addVertexByTapButton.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT,
                LayoutParams.WRAP_CONTENT));
        addVertexByTapButton.setBackground(Compat.getDrawable(context, R.drawable.ic_editing_add_vertex_tap_24dp));
        addVertexByTapButton.setPadding(0, padding, 0, padding);
        addVertexByTapButton.setOnTouchListener(this);
        addVertexByTapButton.setOnClickListener(this);
        parent.addView(addVertexByTapButton);

        undoButton = new ImageButton(context);
        undoButton.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
        undoButton.setBackground(Compat.getDrawable(context, R.drawable.ic_editing_undo_24dp));
        undoButton.setPadding(0, padding, 0, padding);
        undoButton.setOnTouchListener(this);
        undoButton.setOnClickListener(this);
        parent.addView(undoButton);

        commitButton = new ImageButton(context);
        commitButton.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
        commitButton.setBackground(Compat.getDrawable(context, R.drawable.ic_editing_commit_24dp));
        commitButton.setPadding(0, padding, 0, padding);
        commitButton.setOnTouchListener(this);
        commitButton.setOnClickListener(this);
        commitButton.setVisibility(View.GONE);
        parent.addView(commitButton);
    }
}
 

public void initUI() {
        LinearLayout parent = EditManager.INSTANCE.getToolsLayout();
        parent.removeAllViews();

        Context context = parent.getContext();
        IEditableLayer editLayer = EditManager.INSTANCE.getEditLayer();
        int padding = 2;

        if (editLayer != null) {
            deleteFeatureButton = new ImageButton(context);
            deleteFeatureButton.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT,
                    LayoutParams.WRAP_CONTENT));
            deleteFeatureButton.setBackground(Compat.getDrawable(context, R.drawable.ic_editing_delete_feature_24dp));
            deleteFeatureButton.setPadding(0, padding, 0, padding);
            deleteFeatureButton.setOnTouchListener(this);
            deleteFeatureButton.setOnClickListener(this);
            parent.addView(deleteFeatureButton);

//            copyFeatureButton = new ImageButton(context);
//            copyFeatureButton.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT,
//                    LayoutParams.WRAP_CONTENT));
//            copyFeatureButton.setBackground(Compat.getDrawable(context, R.drawable.ic_editing_copy_geoms_24dp));
//            copyFeatureButton.setPadding(0, padding, 0, padding);
//            copyFeatureButton.setOnTouchListener(this);
//            copyFeatureButton.setOnClickListener(this);
//            parent.addView(copyFeatureButton);

            editAttributesButton = new ImageButton(context);
            editAttributesButton.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT,
                    LayoutParams.WRAP_CONTENT));
            editAttributesButton.setBackground(Compat.getDrawable(context, R.drawable.ic_editing_view_attributes_24dp));
            editAttributesButton.setPadding(0, padding, 0, padding);
            editAttributesButton.setOnTouchListener(this);
            editAttributesButton.setOnClickListener(this);
            parent.addView(editAttributesButton);

            undoButton = new ImageButton(context);
            undoButton.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
            undoButton.setBackground(Compat.getDrawable(context, R.drawable.ic_editing_undo_24dp));
            undoButton.setPadding(0, padding, 0, padding);
            undoButton.setOnTouchListener(this);
            undoButton.setOnClickListener(this);
            parent.addView(undoButton);

            commitButton = new ImageButton(context);
            commitButton.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
            commitButton.setBackground(Compat.getDrawable(context, R.drawable.ic_editing_commit_24dp));
            commitButton.setPadding(0, padding, 0, padding);
            commitButton.setOnTouchListener(this);
            commitButton.setOnClickListener(this);
            parent.addView(commitButton);
            commitButton.setVisibility(View.GONE);
        }
    }
 

public void initUI() {

        LinearLayout parent = EditManager.INSTANCE.getToolsLayout();
        Context context = parent.getContext();
        IEditableLayer editLayer = EditManager.INSTANCE.getEditLayer();
        int padding = 2;

        if (editLayer != null) {
            createFeatureButton = new ImageButton(context);
            createFeatureButton.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT,
                    LayoutParams.WRAP_CONTENT));
            createFeatureButton.setBackground(Compat.getDrawable(context, R.drawable.ic_editing_create_line_24dp));
            createFeatureButton.setPadding(0, padding, 0, padding);
            createFeatureButton.setOnClickListener(this);
            createFeatureButton.setOnTouchListener(this);
            parent.addView(createFeatureButton);

            selectEditableButton = new ImageButton(context);
            selectEditableButton.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT,
                    LayoutParams.WRAP_CONTENT));
            selectEditableButton.setBackground(Compat.getDrawable(context, R.drawable.ic_editing_select_editable_24dp));
            selectEditableButton.setPadding(0, padding, 0, padding);
            selectEditableButton.setOnClickListener(this);
            selectEditableButton.setOnTouchListener(this);
            parent.addView(selectEditableButton);
        }

        selectAllButton = new ImageButton(context);
        selectAllButton.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
        Tool activeTool = EditManager.INSTANCE.getActiveTool();
        if (activeTool instanceof InfoTool) {
            selectAllButton.setBackground(Compat.getDrawable(context, R.drawable.ic_editing_select_all_active_24dp));
        } else {
            selectAllButton.setBackground(Compat.getDrawable(context, R.drawable.ic_editing_select_all_24dp));
        }
        selectAllButton.setPadding(0, padding, 0, padding);
        selectAllButton.setOnClickListener(this);
        selectAllButton.setOnTouchListener(this);
        parent.addView(selectAllButton);

        if (editLayer != null) {
            undoButton = new ImageButton(context);
            undoButton.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
            undoButton.setBackground(Compat.getDrawable(context, R.drawable.ic_editing_undo_24dp));
            undoButton.setPadding(0, padding, 0, padding);
            undoButton.setOnTouchListener(this);
            undoButton.setOnClickListener(this);
            parent.addView(undoButton);
            undoButton.setVisibility(View.GONE);

            commitButton = new ImageButton(context);
            commitButton.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
            commitButton.setBackground(Compat.getDrawable(context, R.drawable.ic_editing_commit_24dp));
            commitButton.setPadding(0, padding, 0, padding);
            commitButton.setOnTouchListener(this);
            commitButton.setOnClickListener(this);
            parent.addView(commitButton);
            commitButton.setVisibility(View.GONE);
        }
    }