Java Code Examples for android.widget.FrameLayout#setPadding()

The following examples show how to use android.widget.FrameLayout#setPadding() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: BodyElementTableCell.java    From RedReader with GNU General Public License v3.0 6 votes vote down vote up
@Override
public View generateView(
		@NonNull final AppCompatActivity activity,
		@Nullable final Integer textColor,
		@Nullable final Float textSize,
		final boolean showLinkButtons) {

	// Don't show link buttons inside tables

	final View inner = new BodyElementVerticalSequence(mElements)
			.generateView(activity, textColor, textSize, false);

	final FrameLayout padding = new FrameLayout(activity);
	padding.addView(inner);

	final int verticalPaddingPx = General.dpToPixels(activity, 2);
	final int horizontalPaddingPx = General.dpToPixels(activity, 5);
	padding.setPadding(horizontalPaddingPx, verticalPaddingPx, horizontalPaddingPx, verticalPaddingPx);

	return padding;
}
 
Example 2
Source File: ActionBarLayer.java    From Yahala-Messenger with MIT License 6 votes vote down vote up
public ActionBarLayer(Context context, ActionBar actionBar) {
    super(context);
    parentActionBar = actionBar;
    backButtonFrameLayout = new FrameLayout(context);
    addView(backButtonFrameLayout);
    LayoutParams layoutParams = (LayoutParams) backButtonFrameLayout.getLayoutParams();
    layoutParams.width = LayoutParams.WRAP_CONTENT;
    layoutParams.height = LayoutParams.FILL_PARENT;
    layoutParams.gravity = Gravity.TOP | Gravity.LEFT;
    backButtonFrameLayout.setLayoutParams(layoutParams);
    backButtonFrameLayout.setPadding(0, 0, OSUtilities.dp(4), 0);
    backButtonFrameLayout.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View view) {
            if (isSearchFieldVisible) {
                closeSearchField();
                return;
            }
            if (actionBarMenuOnItemClick != null) {
                actionBarMenuOnItemClick.onItemClick(-1);
            }
        }
    });
    backButtonFrameLayout.setEnabled(false);
}
 
Example 3
Source File: BottomSheetContainer.java    From bottomsheets with Apache License 2.0 6 votes vote down vote up
private void initBottomSheet() {
    mBottomSheetView = new FrameLayout(getContext());
    mBottomSheetView.setLayoutParams(generateDefaultLayoutParams());
    mBottomSheetView.setBackground(createBottomSheetBackgroundDrawable());
    mBottomSheetView.setPadding(
        mBottomSheetView.getPaddingLeft(),
        ((int) mConfig.getExtraPaddingTop()),
        mBottomSheetView.getPaddingRight(),
        ((int) mConfig.getExtraPaddingBottom())
    );

    // Creating the actual sheet content view
    final View createdSheetView = Preconditions.checkNonNull(onCreateSheetContentView(getContext()));

    // adding the created views
    mBottomSheetView.addView(createdSheetView);
    addView(mBottomSheetView);
}
 
Example 4
Source File: DialogUtil.java    From V2EX with GNU General Public License v3.0 6 votes vote down vote up
public static AlertDialog getProgress(Context context,
                                      String title,
                                      @Nullable DialogListener<Boolean> dialogListener){
    AlertDialog.Builder builder = new AlertDialog.Builder(context, getTheme(context));
    builder.setTitle(title);
    FrameLayout.LayoutParams layoutParams = new FrameLayout.LayoutParams(
            ViewGroup.LayoutParams.MATCH_PARENT, 80);
    FrameLayout frameLayout = new FrameLayout(context);
    frameLayout.setLayoutParams(layoutParams);
    frameLayout.setPadding(0,50, 0, 50);
    ProgressBar progressBar = new ProgressBar(context);
    progressBar.setLayoutParams(layoutParams);
    frameLayout.addView(progressBar);
    builder.setView(frameLayout);
    builder.setCancelable(false);
    if (dialogListener != null) builder.setNegativeButton("取 消", (dialog, which) -> {
        dialogListener.onResult(false);
        dialog.dismiss();
    });
    return builder.create();
}
 
Example 5
Source File: SharedPhotoVideoCell.java    From TelePlus-Android with GNU General Public License v2.0 5 votes vote down vote up
public PhotoVideoView(Context context) {
    super(context);

    container = new FrameLayout(context);
    addView(container, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT));

    imageView = new BackupImageView(context);
    imageView.getImageReceiver().setNeedsQualityThumb(true);
    imageView.getImageReceiver().setShouldGenerateQualityThumb(true);
    container.addView(imageView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT));

    videoInfoContainer = new FrameLayout(context);
    videoInfoContainer.setBackgroundResource(R.drawable.phototime);
    videoInfoContainer.setPadding(AndroidUtilities.dp(3), 0, AndroidUtilities.dp(3), 0);
    container.addView(videoInfoContainer, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, 16, Gravity.BOTTOM | Gravity.LEFT));

    ImageView imageView1 = new ImageView(context);
    imageView1.setImageResource(R.drawable.ic_video);
    videoInfoContainer.addView(imageView1, LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, Gravity.LEFT | Gravity.CENTER_VERTICAL));

    videoTextView = new TextView(context);
    videoTextView.setTextColor(0xffffffff);
    videoTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 12);
    videoInfoContainer.addView(videoTextView, LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, Gravity.LEFT | Gravity.CENTER_VERTICAL, 18, -0.7f, 0, 0));

    selector = new View(context);
    selector.setBackgroundDrawable(Theme.getSelectorDrawable(false));
    addView(selector, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT));

    checkBox = new CheckBox(context, R.drawable.round_check2);
    checkBox.setVisibility(INVISIBLE);
    checkBox.setColor(Theme.getColor(Theme.key_checkbox), Theme.getColor(Theme.key_checkboxCheck));
    addView(checkBox, LayoutHelper.createFrame(22, 22, Gravity.RIGHT | Gravity.TOP, 0, 2, 2, 0));
}
 
Example 6
Source File: ColorChooser.java    From LaunchTime with GNU General Public License v3.0 5 votes vote down vote up
private void makeColorPresetButton(int color) {
        FrameLayout outframe = new FrameLayout(getContext());
        outframe.setBackgroundColor(Color.BLACK);
        outframe.setPadding(6,6,6,6);

        FrameLayout frame = new FrameLayout(getContext());
        //frame.setPadding(6,6,6,6);
        //frame.setBackgroundColor(Color.BLACK);
        frame.setBackgroundResource(R.drawable.bwg);

        TextView c = new TextView(getContext());
        c.setText("   ");
        c.setTextSize(22);
        c.setBackgroundColor(color);
//        if (color==Color.TRANSPARENT) {
//            c.setBackgroundResource(R.drawable.transparentgrid);
//        }
        c.setTag(color);
        c.setClickable(true);
        c.setOnClickListener(setColorListener);
        frame.addView(c);
        GridLayout.LayoutParams lp = new GridLayout.LayoutParams();
        lp.setMargins(24, 16, 24, 16);
        outframe.setPadding(6,6,6,6);
        outframe.addView(frame);
        colorPresets.addView(outframe, lp);
    }
 
Example 7
Source File: TabletContentRecyclerAdapterWrapper.java    From ChromeLikeTabSwitcher with Apache License 2.0 5 votes vote down vote up
@NonNull
@Override
public final View onInflateView(@NonNull final LayoutInflater inflater,
                                @Nullable final ViewGroup parent, @NonNull final Tab item,
                                final int viewType, @NonNull final Void... params) {
    View view = encapsulatedAdapter.onInflateView(inflater, parent, item, viewType, params);
    FrameLayout container = new FrameLayout(tabSwitcher.getContext());
    container.setPadding(tabSwitcher.getPaddingLeft(), 0, tabSwitcher.getPaddingRight(),
            tabSwitcher.getPaddingBottom());
    container.setLayoutParams(
            new FrameLayout.LayoutParams(FrameLayout.LayoutParams.MATCH_PARENT,
                    FrameLayout.LayoutParams.MATCH_PARENT));
    container.addView(view);
    return container;
}
 
Example 8
Source File: DialogUtil.java    From V2EX with GNU General Public License v3.0 5 votes vote down vote up
public static void showInputDialog(Context context,
                                   String title,
                                   String msg,
                                   String defaultValue,
                                   DialogListener<String> dialogListener){

    AlertDialog.Builder builder = new AlertDialog.Builder(context, getTheme(context));

    FrameLayout.LayoutParams layoutParams = new FrameLayout.LayoutParams(
            ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
    FrameLayout frameLayout = new FrameLayout(context);
    frameLayout.setLayoutParams(layoutParams);
    EditText editText = new EditText(context);
    editText.setLayoutParams(layoutParams);
    editText.setMaxLines(1);
    frameLayout.addView(editText);
    frameLayout.setPadding(35,25,35,25);

    if (msg != null){
        builder.setMessage(msg);
    }
    if (defaultValue != null){
        editText.setText(defaultValue);
    }
    builder.setTitle(title)
            .setView(frameLayout)
            .setPositiveButton(R.string.confirm, (dialog, which) -> {
                dialogListener.onResult(editText.getText().toString());
                dialog.dismiss();
            })
            .setNegativeButton(R.string.cancel, (dialog, which) -> dialog.dismiss())
            .create()
            .show();
}
 
Example 9
Source File: PhotoPickerPhotoCell.java    From TelePlus-Android with GNU General Public License v2.0 5 votes vote down vote up
public PhotoPickerPhotoCell(Context context, boolean zoom) {
    super(context);

    zoomOnSelect = zoom;

    photoImage = new BackupImageView(context);
    addView(photoImage, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT));

    checkFrame = new FrameLayout(context);
    addView(checkFrame, LayoutHelper.createFrame(42, 42, Gravity.RIGHT | Gravity.TOP));

    videoInfoContainer = new FrameLayout(context);
    videoInfoContainer.setBackgroundResource(R.drawable.phototime);
    videoInfoContainer.setPadding(AndroidUtilities.dp(3), 0, AndroidUtilities.dp(3), 0);
    addView(videoInfoContainer, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, 16, Gravity.BOTTOM | Gravity.LEFT));

    ImageView imageView1 = new ImageView(context);
    imageView1.setImageResource(R.drawable.ic_video);
    videoInfoContainer.addView(imageView1, LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, Gravity.LEFT | Gravity.CENTER_VERTICAL));

    videoTextView = new TextView(context);
    videoTextView.setTextColor(0xffffffff);
    videoTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 12);
    videoInfoContainer.addView(videoTextView, LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, Gravity.LEFT | Gravity.CENTER_VERTICAL, 18, -0.7f, 0, 0));

    checkBox = new CheckBox(context, R.drawable.checkbig);
    checkBox.setSize(zoom ? 30 : 26);
    checkBox.setCheckOffset(AndroidUtilities.dp(1));
    checkBox.setDrawBackground(true);
    checkBox.setColor(0xff66bffa, 0xffffffff);
    addView(checkBox, LayoutHelper.createFrame(zoom ? 30 : 26, zoom ? 30 : 26, Gravity.RIGHT | Gravity.TOP, 0, 4, 4, 0));
}
 
Example 10
Source File: CommentListDialog.java    From xposed-aweme with Apache License 2.0 5 votes vote down vote up
/**
 * 显示编辑的Dialog提示框
 */
private void showEditDialog(String title, String content, final OnEditListener listener) {

    int top = DisplayUtil.dip2px(getContext(), 10f);
    int left = DisplayUtil.dip2px(getContext(), 24f);

    FrameLayout frameLayout = new FrameLayout(getContext());
    frameLayout.setLayoutParams(LayoutUtil.newFrameLayoutParams(
            ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT));
    frameLayout.setPadding(left, top, left, top);

    final EditText editText = new EditText(getContext());
    editText.setText(content);
    editText.setLayoutParams(LayoutUtil.newViewGroupParams(
            ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT));
    ViewUtil.setInputType(editText, com.sky.xposed.common.Constant.InputType.TEXT);
    frameLayout.addView(editText);

    AlertDialog.Builder builder = new AlertDialog.Builder(getContext());
    builder.setTitle(title);
    builder.setView(frameLayout);
    builder.setPositiveButton("确定", new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which) {
            // 返回文本的内容
            listener.onTextChange(editText.getText().toString());
        }
    });
    builder.setNegativeButton("取消", null);
    builder.show();
}
 
Example 11
Source File: UIFlexListView.java    From Auie with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 构建内容视图
 */
private void createContentView() {
	mContentLayout = new RelativeLayout(getContext());
	mContentLayout.setId(1992);
	mContentLayout.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));
	mHeaderView = new FrameLayout(getContext());
	mHeaderView.setLayoutParams(new AbsListView.LayoutParams(AbsListView.LayoutParams.MATCH_PARENT, AbsListView.LayoutParams.MATCH_PARENT));
	mHeaderView.setBackgroundColor(Color.WHITE);
	mHeaderView.setPadding(0, headerHeight, 0, 0);
	mListView = new UIListView(getContext());
	mListView.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));
	mListView.setType(UIListView.TYPE_NONE);
	mListView.addHeaderView(mHeaderView);
	mListView.setBackgroundColor(Color.WHITE);
	mListView.setOnScrollListener(this);
	mHeaderLayout = new LinearLayout(getContext());
	mHeaderLayout.setOrientation(LinearLayout.VERTICAL);
	mHeaderLayout.setBackgroundColor(Color.WHITE);
	mHeaderLayout.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT));
	mHeaderLayout.getViewTreeObserver().addOnGlobalLayoutListener(new OnGlobalLayoutListener() {
		@Override
		public void onGlobalLayout() {
			headerHeight = mHeaderLayout.getHeight();
			resetHeaderView(headerHeight);
		}
	});
	mHeaderContentLayout = new LinearLayout(getContext());
	mHeaderContentLayout.setOrientation(LinearLayout.VERTICAL);
	mHeaderContentLayout.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT));
	mHeaderActionBarLayout = new LinearLayout(getContext());
	mHeaderActionBarLayout.setBackgroundColor(Color.GRAY);
	mHeaderActionBarLayout.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT));
	mHeaderLayout.addView(mHeaderContentLayout);
	mHeaderLayout.addView(mHeaderActionBarLayout);
	mContentLayout.addView(mListView);
	addView(mContentLayout);
	addView(mHeaderLayout);
}
 
Example 12
Source File: PhotoPickerPhotoCell.java    From TelePlus-Android with GNU General Public License v2.0 5 votes vote down vote up
public PhotoPickerPhotoCell(Context context, boolean zoom) {
    super(context);

    zoomOnSelect = zoom;

    photoImage = new BackupImageView(context);
    addView(photoImage, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT));

    checkFrame = new FrameLayout(context);
    addView(checkFrame, LayoutHelper.createFrame(42, 42, Gravity.RIGHT | Gravity.TOP));

    videoInfoContainer = new FrameLayout(context);
    videoInfoContainer.setBackgroundResource(R.drawable.phototime);
    videoInfoContainer.setPadding(AndroidUtilities.dp(3), 0, AndroidUtilities.dp(3), 0);
    addView(videoInfoContainer, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, 16, Gravity.BOTTOM | Gravity.LEFT));

    ImageView imageView1 = new ImageView(context);
    imageView1.setImageResource(R.drawable.ic_video);
    videoInfoContainer.addView(imageView1, LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, Gravity.LEFT | Gravity.CENTER_VERTICAL));

    videoTextView = new TextView(context);
    videoTextView.setTextColor(0xffffffff);
    videoTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 12);
    videoInfoContainer.addView(videoTextView, LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, Gravity.LEFT | Gravity.CENTER_VERTICAL, 18, -0.7f, 0, 0));

    checkBox = new CheckBox(context, R.drawable.checkbig);
    checkBox.setSize(zoom ? 30 : 26);
    checkBox.setCheckOffset(AndroidUtilities.dp(1));
    checkBox.setDrawBackground(true);
    checkBox.setColor(0xff66bffa, 0xffffffff);
    addView(checkBox, LayoutHelper.createFrame(zoom ? 30 : 26, zoom ? 30 : 26, Gravity.RIGHT | Gravity.TOP, 0, 4, 4, 0));
}
 
Example 13
Source File: DynamicAlertController.java    From dynamic-support with Apache License 2.0 4 votes vote down vote up
private void setupCustomContent(ViewGroup customPanel) {
    final View customView;
    if (mView != null) {
        customView = mView;
    } else if (mViewLayoutResId != 0) {
        final LayoutInflater inflater = LayoutInflater.from(mContext);
        customView = inflater.inflate(mViewLayoutResId, customPanel, false);
    } else {
        customView = null;
    }

    if (customView != null && mViewRoot == null) {
        if (mViewRootId != 0) {
            mViewRoot = customView.findViewById(mViewRootId);

            if (mViewRoot == null) {
                throw new NullPointerException("Unable to find root view for the supplied id "
                        + mViewRootId + ".");
            }
        }
    }

    final boolean hasCustomView = customView != null;
    if (!hasCustomView || !canTextInput(customView)) {
        mWindow.setFlags(WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM,
                WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM);
    }

    if (hasCustomView) {
        final FrameLayout custom = mWindow.findViewById(R.id.custom);
        custom.addView(customView, new ViewGroup.LayoutParams(MATCH_PARENT, MATCH_PARENT));

        if (mViewSpacingSpecified) {
            custom.setPadding(
                    mViewSpacingLeft, mViewSpacingTop, mViewSpacingRight, mViewSpacingBottom);
        }

        if (mListView != null) {
            ((LinearLayout.LayoutParams) customPanel.getLayoutParams()).weight = 0;
        }
    } else {
        customPanel.setVisibility(View.GONE);
    }
}
 
Example 14
Source File: PhotoPickerPhotoCell.java    From Telegram with GNU General Public License v2.0 4 votes vote down vote up
public PhotoPickerPhotoCell(Context context) {
    super(context);
    setWillNotDraw(false);

    imageView = new BackupImageView(context);
    imageView.setRoundRadius(AndroidUtilities.dp(4));
    addView(imageView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT));

    checkFrame = new FrameLayout(context);
    addView(checkFrame, LayoutHelper.createFrame(42, 42, Gravity.RIGHT | Gravity.TOP));

    videoInfoContainer = new FrameLayout(context) {

        private Path path = new Path();
        float[] radii = new float[8];
        private RectF rect = new RectF();
        private Paint paint = new Paint(Paint.ANTI_ALIAS_FLAG);

        @Override
        protected void onDraw(Canvas canvas) {
            rect.set(0, 0, getMeasuredWidth(), getMeasuredHeight());
            radii[0] = radii[1] = radii[2] = radii[3] = 0;
            radii[4] = radii[5] = radii[6] = radii[7] = AndroidUtilities.dp(4);
            path.reset();
            path.addRoundRect(rect, radii, Path.Direction.CW);
            path.close();
            paint.setColor(0x7f000000);
            canvas.drawPath(path, paint);
        }
    };
    videoInfoContainer.setWillNotDraw(false);
    videoInfoContainer.setPadding(AndroidUtilities.dp(3), 0, AndroidUtilities.dp(3), 0);
    addView(videoInfoContainer, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, 16, Gravity.BOTTOM | Gravity.LEFT));

    ImageView imageView1 = new ImageView(context);
    imageView1.setImageResource(R.drawable.ic_video);
    videoInfoContainer.addView(imageView1, LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, Gravity.LEFT | Gravity.CENTER_VERTICAL));

    videoTextView = new TextView(context);
    videoTextView.setTextColor(0xffffffff);
    videoTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 12);
    videoTextView.setImportantForAccessibility(IMPORTANT_FOR_ACCESSIBILITY_NO);
    videoInfoContainer.addView(videoTextView, LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, Gravity.LEFT | Gravity.CENTER_VERTICAL, 18, -0.7f, 0, 0));

    checkBox = new CheckBox2(context, 24);
    checkBox.setDrawBackgroundAsArc(11);
    checkBox.setColor(Theme.key_chat_attachCheckBoxBackground, Theme.key_chat_attachPhotoBackground, Theme.key_chat_attachCheckBoxCheck);
    addView(checkBox, LayoutHelper.createFrame(26, 26, Gravity.LEFT | Gravity.TOP, 55, 4, 0, 0));
    checkBox.setVisibility(VISIBLE);

    setFocusable(true);
}
 
Example 15
Source File: WallpaperPickerActivity.java    From LB-Launcher with Apache License 2.0 4 votes vote down vote up
static void setWallpaperItemPaddingToZero(FrameLayout frameLayout) {
    frameLayout.setPadding(0, 0, 0, 0);
    frameLayout.setForeground(new ZeroPaddingDrawable(frameLayout.getForeground()));
}
 
Example 16
Source File: MLAlertController.java    From NewXmPluginSDK with Apache License 2.0 4 votes vote down vote up
private void setupView() {
        LinearLayout contentPanel = (LinearLayout) mWindow.findViewById(R.id.contentPanel);
        setupContent(contentPanel);
        boolean hasButtons = setupButtons();

        LinearLayout topPanel = (LinearLayout) mWindow.findViewById(R.id.topPanel);
        boolean hasTitle = setupTitle(topPanel);

        View buttonPanel = mWindow.findViewById(R.id.buttonPanel);
        if (!hasButtons) {
            buttonPanel.setVisibility(View.GONE);
        }

        FrameLayout customPanel = (FrameLayout) mWindow.findViewById(R.id.customPanel);
        if (mView != null) {
            // 自定义dialog透明背景
            // mWindow.findViewById(R.id.parentPanel).setBackgroundColor(mContext.getResources().getColor(android.R.color.transparent));
            FrameLayout custom = (FrameLayout) mWindow.findViewById(R.id.custom);
            custom.addView(mView);
            if (mViewSpacingSpecified) {
                custom.setPadding(mViewSpacingLeft, mViewSpacingTop, mViewSpacingRight,
                        mViewSpacingBottom);
                if (mCustomBgTransplant)
                    mTransplantBg = true;
            }
            if (mListView != null) {
                ((LinearLayout.LayoutParams) customPanel.getLayoutParams()).weight = 0;
            }
        } else {
            customPanel.setVisibility(View.GONE);
        }

        if (mTransplantBg) {
            mWindow.findViewById(R.id.parentPanel).setBackgroundColor(
                    mContext.getResources().getColor(android.R.color.transparent));
        } else {
//            mWindow.findViewById(R.id.parentPanel).setBackgroundColor(0xffffffff);
        }

        if (mListView != null) {
            // Listview有分割线divider,因此header和listview需要显示分割线
            mWindow.findViewById(R.id.title_divider_line).setVisibility(View.VISIBLE);
            mWindow.findViewById(R.id.title_divider_line_bottom).setVisibility(View.VISIBLE);
        } else {
            mWindow.findViewById(R.id.title_divider_line).setVisibility(View.GONE);
            mWindow.findViewById(R.id.title_divider_line_bottom).setVisibility(View.GONE);
        }
        /**
         * Add margin top for the button panel if we have not any panel
         */
        if (topPanel.getVisibility() == View.GONE && contentPanel.getVisibility() == View.GONE
                && customPanel.getVisibility() == View.GONE && hasButtons) {
            buttonPanel.setPadding(buttonPanel.getPaddingLeft(), buttonPanel.getPaddingBottom(),
                    buttonPanel.getPaddingRight(), buttonPanel.getPaddingBottom());
        }

        /*
         * Only display the divider if we have a title and a custom view or a
         * message.
         */
        if (hasTitle) {
            // View divider = null;
            // if (mMessage != null || mView != null || mListView != null) {
            // divider = mWindow.findViewById(R.id.titleDivider);
            // } else {
            // divider = mWindow.findViewById(R.id.titleDividerTop);
            // }
            //
            // if (divider != null) {
            // divider.setVisibility(View.VISIBLE);
            // }
        }
        setBackground(topPanel, contentPanel, customPanel, hasButtons, hasTitle, buttonPanel);
        if (TextUtils.isEmpty(mTitle) && TextUtils.isEmpty(mMessage)) {
            mWindow.findViewById(R.id.empty_view).setVisibility(View.GONE);
        }
    }
 
Example 17
Source File: WallpaperPickerActivity.java    From TurboLauncher with Apache License 2.0 4 votes vote down vote up
static void setWallpaperItemPaddingToZero(FrameLayout frameLayout) {
    frameLayout.setPadding(0, 0, 0, 0);
    frameLayout.setForeground(new ZeroPaddingDrawable(frameLayout.getForeground()));
}
 
Example 18
Source File: ViewMaker.java    From iGap-Android with GNU Affero General Public License v3.0 4 votes vote down vote up
static View getFileItem() {

        LinearLayout mainContainer = new LinearLayout(G.context);
        mainContainer.setId(R.id.mainContainer);
        mainContainer.setOrientation(HORIZONTAL);
        LinearLayout.LayoutParams layout_106 = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT);
        mainContainer.setLayoutParams(layout_106);

        LinearLayout linearLayout_768 = new LinearLayout(G.context);
        linearLayout_768.setOrientation(VERTICAL);
        LinearLayout.LayoutParams layout_577 = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT);
        linearLayout_768.setLayoutParams(layout_577);

        LinearLayout contentContainer = new LinearLayout(G.context);
        LinearLayout.LayoutParams layoutParamsContentContainer = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
        contentContainer.setId(R.id.contentContainer);
        contentContainer.setLayoutParams(layoutParamsContentContainer);
        contentContainer.setPadding(i_Dp(R.dimen.dp4), i_Dp(R.dimen.dp4), i_Dp(R.dimen.dp4), i_Dp(R.dimen.dp4));
        contentContainer.setLayoutParams(layoutParamsContentContainer);

        LinearLayout m_container = new LinearLayout(G.context);
        m_container.setId(R.id.m_container);
        m_container.setOrientation(VERTICAL);
        LinearLayout.LayoutParams layout_346 = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT);
        m_container.setLayoutParams(layout_346);

        LinearLayout linearLayout_784 = new LinearLayout(G.context);
        linearLayout_784.setGravity(Gravity.CENTER_VERTICAL);
        setLayoutDirection(linearLayout_784, View.LAYOUT_DIRECTION_LTR);
        linearLayout_784.setOrientation(HORIZONTAL);
        linearLayout_784.setPadding(0, 0, (int) G.context.getResources().getDimension(R.dimen.messageContainerPadding), 0);
        LinearLayout.LayoutParams layout_419 = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT);
        layout_419.gravity = CENTER;
        linearLayout_784.setLayoutParams(layout_419);

        FrameLayout frameLayout = new FrameLayout(G.context);
        FrameLayout.LayoutParams layoutParamsFrameLayout = new FrameLayout.LayoutParams(FrameLayout.LayoutParams.WRAP_CONTENT, FrameLayout.LayoutParams.WRAP_CONTENT);
        layoutParamsFrameLayout.gravity = CENTER;
        frameLayout.setPadding(10, 10, 10, 10);
        frameLayout.setLayoutParams(layoutParamsFrameLayout);

        ImageView imgThumbnail = new ImageView(G.context);
        imgThumbnail.setId(R.id.thumbnail);
        LinearLayout.LayoutParams thumbnailParams = new LinearLayout.LayoutParams((int) G.context.getResources().getDimension(R.dimen.dp48), (int) G.context.getResources().getDimension(R.dimen.dp48));
        thumbnailParams.gravity = CENTER;
        imgThumbnail.setBackgroundColor(Color.TRANSPARENT);
        imgThumbnail.setScaleType(ImageView.ScaleType.FIT_CENTER);
        AppUtils.setImageDrawable(imgThumbnail, R.drawable.file_icon);
        imgThumbnail.setLayoutParams(thumbnailParams);

        LinearLayout linearLayout_780 = new LinearLayout(G.context);
        linearLayout_780.setOrientation(VERTICAL);
        LinearLayout.LayoutParams layout_752 = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT);
        layout_752.gravity = CENTER;
        linearLayout_780.setLayoutParams(layout_752);

        TextView songArtist = new TextView(G.context);
        songArtist.setId(R.id.songArtist);
        songArtist.setEllipsize(TextUtils.TruncateAt.MIDDLE);
        songArtist.setSingleLine(true);

        songArtist.setMaxWidth((int) G.context.getResources().getDimension(R.dimen.dp180));
        songArtist.setText("file_name.ext");
        songArtist.setTextColor(Color.parseColor(G.textBubble));
        setTextSize(songArtist, R.dimen.dp14);
        songArtist.setTypeface(G.typeface_IRANSansMobile_Bold, BOLD);
        LinearLayout.LayoutParams layout_1000 = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT);
        songArtist.setLayoutParams(layout_1000);
        linearLayout_780.addView(songArtist);

        TextView fileSize = new TextView(G.context);
        fileSize.setId(R.id.fileSize);
        fileSize.setSingleLine(true);
        fileSize.setText("3.2 mb");
        fileSize.setAllCaps(TRUE);
        fileSize.setTextColor(Color.parseColor(G.textBubble));
        setTextSize(fileSize, R.dimen.dp10);
        setTypeFace(fileSize);
        LinearLayout.LayoutParams layout_958 = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT);
        layout_958.topMargin = 3;
        fileSize.setLayoutParams(layout_958);
        linearLayout_780.addView(fileSize);
        linearLayout_784.addView(frameLayout);
        linearLayout_784.addView(linearLayout_780);
        m_container.addView(linearLayout_784);

        LinearLayout csliwt_layout_container_message = new LinearLayout(G.context);
        csliwt_layout_container_message.setId(R.id.csliwt_layout_container_message);
        csliwt_layout_container_message.setOrientation(HORIZONTAL);
        LinearLayout.LayoutParams layout_312 = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT);
        csliwt_layout_container_message.setLayoutParams(layout_312);
        m_container.addView(csliwt_layout_container_message);
        contentContainer.addView(m_container);
        linearLayout_768.addView(contentContainer);

        frameLayout.addView(imgThumbnail);
        frameLayout.addView(getProgressBar(R.dimen.dp52));
        mainContainer.addView(linearLayout_768);

        return mainContainer;
    }
 
Example 19
Source File: ThreadsAdapter.java    From Dashchan with Apache License 2.0 4 votes vote down vote up
public ThreadsAdapter(Context context, String chanName, String boardName, UiManager uiManager) {
	this.context = context;
	this.chanName = chanName;
	this.boardName = boardName;
	this.uiManager = uiManager;
	hidePerformer = new HidePerformer();
	float density = ResourceUtils.obtainDensity(context);
	FrameLayout frameLayout = new FrameLayout(context);
	frameLayout.setPadding((int) (10f * density), (int) (6f * density), (int) (10f * density), 0);
	headerClickableView = new ClickableView(context);
	headerClickableView.setOnClickListener(this);
	frameLayout.addView(headerClickableView, FrameLayout.LayoutParams.MATCH_PARENT,
			FrameLayout.LayoutParams.MATCH_PARENT);
	LinearLayout linearLayout = new LinearLayout(context);
	linearLayout.setOrientation(LinearLayout.VERTICAL);
	frameLayout.addView(linearLayout, FrameLayout.LayoutParams.MATCH_PARENT,
			FrameLayout.LayoutParams.WRAP_CONTENT);
	linearLayout.setPadding((int) (10f * density), (int) (4f * density),
			(int) (10f * density), (int) (4f * density));
	LinearLayout innerLayout = new LinearLayout(context);
	innerLayout.setOrientation(LinearLayout.HORIZONTAL);
	linearLayout.addView(innerLayout, LinearLayout.LayoutParams.MATCH_PARENT,
			LinearLayout.LayoutParams.WRAP_CONTENT);
	LinearLayout topLayout = new LinearLayout(context);
	topLayout.setOrientation(LinearLayout.VERTICAL);
	innerLayout.addView(topLayout, new LinearLayout.LayoutParams(0, LinearLayout.LayoutParams.WRAP_CONTENT, 1f));
	headerData[0] = new TextView(context, null, android.R.attr.textAppearanceLarge);
	headerData[0].setTextSize(18f);
	if (C.API_LOLLIPOP) {
		headerData[0].setTypeface(GraphicsUtils.TYPEFACE_MEDIUM);
	}
	topLayout.addView(headerData[0], LinearLayout.LayoutParams.MATCH_PARENT,
			LinearLayout.LayoutParams.WRAP_CONTENT);
	headerData[1] = new TextView(context, null, android.R.attr.textAppearanceSmall);
	topLayout.addView(headerData[1], LinearLayout.LayoutParams.MATCH_PARENT,
			LinearLayout.LayoutParams.WRAP_CONTENT);
	headerData[1].setPadding(0, (int) (2f * density), 0, (int) (2f * density));
	headerExpandIcon = new ImageView(context);
	headerExpandIcon.setImageResource(ResourceUtils.getResourceId(context, R.attr.buttonDropDown, 0));
	innerLayout.addView(headerExpandIcon, (int) (24f * density), (int) (24f * density));
	LinearLayout.LayoutParams iconLayoutParams = (LinearLayout.LayoutParams) headerExpandIcon.getLayoutParams();
	iconLayoutParams.gravity = Gravity.BOTTOM;
	iconLayoutParams.setMargins((int) (4f * density), 0, (int) (-6f * density), 0);
	LinearLayout headerAdditional = new LinearLayout(context);
	headerAdditional.setOrientation(LinearLayout.VERTICAL);
	this.headerAdditional = headerAdditional;
	linearLayout.addView(headerAdditional, LinearLayout.LayoutParams.MATCH_PARENT,
			LinearLayout.LayoutParams.WRAP_CONTENT);
	for (int i = 2; i < 6; i += 2) {
		headerData[i] = new TextView(context, null, android.R.attr.textAppearanceLarge);
		headerData[i].setTextSize(16f);
		if (C.API_LOLLIPOP) {
			headerData[i].setTypeface(headerData[0].getTypeface());
		}
		headerData[i].setPadding(0, (int) (8f * density), 0, (int) (4f * density));
		headerAdditional.addView(headerData[i], LinearLayout.LayoutParams.MATCH_PARENT,
				LinearLayout.LayoutParams.WRAP_CONTENT);
		headerData[i + 1] = new TextView(context, null, android.R.attr.textAppearanceSmall);
		headerData[i + 1].setLineSpacing((int) (2f * density), 1f);
		headerAdditional.addView(headerData[i + 1], LinearLayout.LayoutParams.MATCH_PARENT,
				LinearLayout.LayoutParams.WRAP_CONTENT);
		headerData[i + 1].setPadding(0, 0, 0, (int) (2f * density));
	}
	headerData[4].setText(context.getString(R.string.text_configuration));
	LinearLayout radioButtonsContainer = new LinearLayout(context);
	radioButtonsContainer.setOrientation(LinearLayout.VERTICAL);
	radioButtonsContainer.setClickable(true);
	headerAdditional.addView(radioButtonsContainer, LinearLayout.LayoutParams.MATCH_PARENT,
			LinearLayout.LayoutParams.WRAP_CONTENT);
	for (int i = 0; i < sortingData.length; i++) {
		sortingData[i] = new RadioButton(context);
		sortingData[i].setOnCheckedChangeListener(this);
		radioButtonsContainer.addView(sortingData[i], LinearLayout.LayoutParams.WRAP_CONTENT,
				LinearLayout.LayoutParams.WRAP_CONTENT);
		ViewGroup.MarginLayoutParams layoutParams = (ViewGroup.MarginLayoutParams) sortingData[i]
				.getLayoutParams();
		if (i == 0) {
			layoutParams.topMargin = (int) (4f * density);
		}
		if (C.API_LOLLIPOP) {
			layoutParams.leftMargin = (int) (-4f * density);
		}
	}
	sortingData[0].setText(context.getString(R.string.text_sort_by_unsorted));
	sortingData[1].setText(context.getString(R.string.text_sort_by_date));
	sortingData[2].setText(context.getString(R.string.text_sort_by_replies));
	sortingData[0].setChecked(true);
	headerView = frameLayout;
}
 
Example 20
Source File: PhotoAttachPhotoCell.java    From Telegram with GNU General Public License v2.0 4 votes vote down vote up
public PhotoAttachPhotoCell(Context context) {
    super(context);

    setWillNotDraw(false);

    container = new FrameLayout(context);
    addView(container, LayoutHelper.createFrame(80, 80));

    imageView = new BackupImageView(context);
    container.addView(imageView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT));

    videoInfoContainer = new FrameLayout(context) {

        private RectF rect = new RectF();

        @Override
        protected void onDraw(Canvas canvas) {
            rect.set(0, 0, getMeasuredWidth(), getMeasuredHeight());
            canvas.drawRoundRect(rect, AndroidUtilities.dp(4), AndroidUtilities.dp(4), Theme.chat_timeBackgroundPaint);
        }
    };
    videoInfoContainer.setWillNotDraw(false);
    videoInfoContainer.setPadding(AndroidUtilities.dp(5), 0, AndroidUtilities.dp(5), 0);
    container.addView(videoInfoContainer, LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT, 17, Gravity.BOTTOM | Gravity.LEFT, 4, 0, 0, 4));

    ImageView imageView1 = new ImageView(context);
    imageView1.setImageResource(R.drawable.play_mini_video);
    videoInfoContainer.addView(imageView1, LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, Gravity.LEFT | Gravity.CENTER_VERTICAL));

    videoTextView = new TextView(context);
    videoTextView.setTextColor(0xffffffff);
    videoTextView.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf"));
    videoTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 12);
    videoTextView.setImportantForAccessibility(IMPORTANT_FOR_ACCESSIBILITY_NO);
    videoInfoContainer.addView(videoTextView, LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, Gravity.LEFT | Gravity.CENTER_VERTICAL, 13, -0.7f, 0, 0));

    checkBox = new CheckBox2(context, 24);
    checkBox.setDrawBackgroundAsArc(7);
    checkBox.setColor(Theme.key_chat_attachCheckBoxBackground, Theme.key_chat_attachPhotoBackground, Theme.key_chat_attachCheckBoxCheck);
    addView(checkBox, LayoutHelper.createFrame(26, 26, Gravity.LEFT | Gravity.TOP, 52, 4, 0, 0));
    checkBox.setVisibility(VISIBLE);
    setFocusable(true);

    checkFrame = new FrameLayout(context);
    addView(checkFrame, LayoutHelper.createFrame(42, 42, Gravity.LEFT | Gravity.TOP, 38, 0, 0, 0));

    itemSize = AndroidUtilities.dp(80);
}