Java Code Examples for android.view.View#setMinimumWidth()

The following examples show how to use android.view.View#setMinimumWidth() . 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: ServerDialog.java    From an2linuxclient with GNU General Public License v3.0 6 votes vote down vote up
void initViews(View v) {
    getDialog().requestWindowFeature(Window.FEATURE_NO_TITLE);
    getDialog().getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE);
    getDialog().getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN);

    Rect displayRectangle = new Rect();
    Window window = getActivity().getWindow();
    window.getDecorView().getWindowVisibleDisplayFrame(displayRectangle);
    v.setMinimumWidth((int)(displayRectangle.width() * 0.9f));

    pairingInfoTextView = (TextView) v.findViewById(R.id.pairingInfoTextView);
    initiatePairingButton = (Button) v.findViewById(R.id.initiatePairingButton);
    saveServerBtn = (Button) v.findViewById(R.id.saveServerBtn);

    v.findViewById(R.id.cancelBtn).setOnClickListener(view -> cancel());
}
 
Example 2
Source File: VoteDialog.java    From Elephant with Apache License 2.0 5 votes vote down vote up
private void initContentView() {
    View view = LayoutInflater.from(mContext).inflate(R.layout.dialog_vote, null);

    Rect displayRectangle = new Rect();
    Window window = getWindow();
    window.getDecorView().getWindowVisibleDisplayFrame(displayRectangle);
    view.setMinimumWidth((int) (displayRectangle.width() * 0.8f));
    window.setBackgroundDrawableResource(R.color.dialog_bg);

    setContentView(view);
}
 
Example 3
Source File: MinWidthAttr.java    From AndroidAutoLayout with Apache License 2.0 5 votes vote down vote up
@Override
    protected void execute(View view, int val)
    {
        try
        {
//            Method setMaxWidthMethod = view.getClass().getMethod("setMinWidth", int.class);
//            setMaxWidthMethod.invoke(view, val);
        } catch (Exception ignore)
        {
        }

        view.setMinimumWidth(val);
    }
 
Example 4
Source File: BaseFragmentTabHost.java    From FragmentMixViewPager with Apache License 2.0 5 votes vote down vote up
@Override
public View createTabContent(String tag) {
	View v = new View(mContext);
	v.setMinimumWidth(0);
	v.setMinimumHeight(0);
	return v;
}
 
Example 5
Source File: FragmentTabHost.java    From AndroidBase with Apache License 2.0 5 votes vote down vote up
@Override
public View createTabContent(String tag) {
    View v = new View(mContext);
    v.setMinimumWidth(0);
    v.setMinimumHeight(0);
    return v;
}
 
Example 6
Source File: FragmentTabHost.java    From V.FlyoutTest with MIT License 5 votes vote down vote up
@Override
public View createTabContent(String tag) {
    View v = new View(mContext);
    v.setMinimumWidth(0);
    v.setMinimumHeight(0);
    return v;
}
 
Example 7
Source File: HelpFragment.java    From RobotCA with GNU General Public License v3.0 5 votes vote down vote up
public View createTabContent(String tag)
{
    View v = new View(mContext);
    v.setMinimumWidth(0);
    v.setMinimumHeight(0);
    return v;
}
 
Example 8
Source File: FragmentTabHost.java    From enjoyshop with Apache License 2.0 5 votes vote down vote up
@Override
public View createTabContent(String tag) {
    View v = new View(mContext);
    v.setMinimumWidth(0);
    v.setMinimumHeight(0);
    return v;
}
 
Example 9
Source File: SizeUtils.java    From Matisse with Apache License 2.0 5 votes vote down vote up
@SuppressLint({"NewApi"})
public static void scaleView(View view) {
    if ((view instanceof TextView)) {
        TextView textView = (TextView) view;
        setTextSize(textView, textView.getTextSize());
    }

    ViewGroup.LayoutParams params = view.getLayoutParams();
    if (null != params) {
        int width = -2147483648;
        int height = -2147483648;
        if ((params.width != -2) && (params.width != -1)) {
            width = params.width;
        }

        if ((params.height != -2) && (params.height != -1)) {
            height = params.height;
        }

        setViewSize(view, width, height);

        setPadding(view, view.getPaddingLeft(), view.getPaddingTop(), view.getPaddingRight(), view.getPaddingBottom());
    }

    if ((view.getLayoutParams() instanceof ViewGroup.MarginLayoutParams)) {
        ViewGroup.MarginLayoutParams mMarginLayoutParams = (ViewGroup.MarginLayoutParams) view
                .getLayoutParams();
        if (mMarginLayoutParams != null) {
            setMargin(view, mMarginLayoutParams.leftMargin, mMarginLayoutParams.topMargin, mMarginLayoutParams.rightMargin, mMarginLayoutParams.bottomMargin);
        }
    }

    if (Build.VERSION.SDK_INT >= 16) {
        int minWidth = scaleValue(view.getContext(), view.getMinimumWidth());
        int minHeight = scaleValue(view.getContext(), view.getMinimumHeight());
        view.setMinimumWidth(minWidth);
        view.setMinimumHeight(minHeight);
    }
}
 
Example 10
Source File: ViewSpanTest.java    From TokenAutoComplete with Apache License 2.0 5 votes vote down vote up
@Test
public void correctLineHeightWithoutBaseline() {
    View view = new View(context);
    view.setMinimumHeight(1000);
    view.setMinimumWidth(1000);

    ViewSpan span = new ViewSpan(view, layout);
    Paint paint = new Paint();
    Paint.FontMetricsInt fontMetricsInt = paint.getFontMetricsInt();
    int width = span.getSize(paint, "", 0, 0, fontMetricsInt);
    assertEquals(100, width);
    assertEquals(0, fontMetricsInt.bottom);
    assertEquals(-view.getHeight(), fontMetricsInt.top);
}
 
Example 11
Source File: OpenTabHost.java    From Android-tv-widget with Apache License 2.0 5 votes vote down vote up
/**
 * 创建一个空的Content.
 */
@Override
public View createTabContent(String tag) {
	View v = new View(mContext);
	v.setMinimumWidth(0);
	v.setMinimumHeight(0);
	return v;
}
 
Example 12
Source File: MinWidthAttr.java    From AutoLayout-Android with Apache License 2.0 5 votes vote down vote up
@Override
protected void execute(View view, int val) {
    view.setMinimumWidth(val);
    if (view instanceof TextView) {
        ((TextView) view).setMinWidth(val);
    } else if (view instanceof ProgressBar) {
        try {
            Field field = view.getClass().getDeclaredField("mMinWidth");
            field.setAccessible(true);
            field.set(view, val);
        } catch (Exception e) {
        }
    }
}
 
Example 13
Source File: FragmentTabHost.java    From CodenameOne with GNU General Public License v2.0 5 votes vote down vote up
@Override
public View createTabContent(String tag) {
    View v = new View(mContext);
    v.setMinimumWidth(0);
    v.setMinimumHeight(0);
    return v;
}
 
Example 14
Source File: MainActivity.java    From android_tv_metro with Apache License 2.0 5 votes vote down vote up
@Override
public View createTabContent(String tag) {
    View v = new View(mContext);
    v.setMinimumWidth(0);
    v.setMinimumHeight(0);
    return v;
}
 
Example 15
Source File: FragmentTabHost.java    From ImitateTaobaoApp with Apache License 2.0 5 votes vote down vote up
@Override
public View createTabContent(String tag) {
    View v = new View(mContext);
    v.setMinimumWidth(0);
    v.setMinimumHeight(0);
    return v;
}
 
Example 16
Source File: ViewUtils.java    From DevUtils with Apache License 2.0 5 votes vote down vote up
/**
 * 设置 View 最小宽度
 * @param view     {@link View}
 * @param minWidth 最小宽度
 * @return {@link View}
 */
public static View setMinimumWidth(final View view, final int minWidth) {
    if (view != null) {
        view.setMinimumWidth(minWidth);
    }
    return view;
}
 
Example 17
Source File: AbViewUtil.java    From FimiX8-RE with MIT License 5 votes vote down vote up
@SuppressLint({"NewApi"})
public static void scaleView(View view) {
    if (view instanceof TextView) {
        TextView textView = (TextView) view;
        setTextSize(textView, textView.getTextSize());
    }
    LayoutParams params = view.getLayoutParams();
    if (params != null) {
        int width = Integer.MIN_VALUE;
        int height = Integer.MIN_VALUE;
        if (!(params.width == -2 || params.width == -1)) {
            width = params.width;
        }
        if (!(params.height == -2 || params.height == -1)) {
            height = params.height;
        }
        setViewSize(view, width, height);
        setPadding(view, view.getPaddingLeft(), view.getPaddingTop(), view.getPaddingRight(), view.getPaddingBottom());
    }
    if (view.getLayoutParams() instanceof MarginLayoutParams) {
        MarginLayoutParams mMarginLayoutParams = (MarginLayoutParams) view.getLayoutParams();
        if (mMarginLayoutParams != null) {
            setMargin(view, mMarginLayoutParams.leftMargin, mMarginLayoutParams.topMargin, mMarginLayoutParams.rightMargin, mMarginLayoutParams.bottomMargin);
        }
    }
    if (VERSION.SDK_INT >= 16) {
        int minWidth = scaleValue(view.getContext(), (float) view.getMinimumWidth());
        int minHeight = scaleValue(view.getContext(), (float) view.getMinimumHeight());
        view.setMinimumWidth(minWidth);
        view.setMinimumHeight(minHeight);
    }
}
 
Example 18
Source File: FragmentTabHost.java    From letv with Apache License 2.0 4 votes vote down vote up
public View createTabContent(String tag) {
    View v = new View(this.mContext);
    v.setMinimumWidth(0);
    v.setMinimumHeight(0);
    return v;
}
 
Example 19
Source File: SlideTabsFactory.java    From GPS2SMS with GNU General Public License v3.0 4 votes vote down vote up
public View createTabContent(String tag) {
    View v = new View(mContext);
    v.setMinimumWidth(0);
    v.setMinimumHeight(0);
    return v;
}
 
Example 20
Source File: TabsAdapter.java    From callerid-for-android with GNU General Public License v3.0 4 votes vote down vote up
public View createTabContent(String tag) {
    View v = new View(mContext);
    v.setMinimumWidth(0);
    v.setMinimumHeight(0);
    return v;
}