Search in sources :

Example 76 with LayoutParams

use of android.view.ViewGroup.LayoutParams in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class EmptyTextSettings method onViewCreated.

@Override
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);
    mEmpty = new TextView(getContext());
    mEmpty.setGravity(Gravity.CENTER);
    TypedValue value = new TypedValue();
    getContext().getTheme().resolveAttribute(android.R.attr.textAppearanceMedium, value, true);
    mEmpty.setTextAppearance(value.resourceId);
    ((ViewGroup) view.findViewById(android.R.id.list_container)).addView(mEmpty, new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));
    setEmptyView(mEmpty);
}
Also used : LayoutParams(android.view.ViewGroup.LayoutParams) ViewGroup(android.view.ViewGroup) TextView(android.widget.TextView) TypedValue(android.util.TypedValue)

Example 77 with LayoutParams

use of android.view.ViewGroup.LayoutParams in project android_frameworks_base by ResurrectionRemix.

the class KeyboardView method showKey.

private void showKey(final int keyIndex) {
    final PopupWindow previewPopup = mPreviewPopup;
    final Key[] keys = mKeys;
    if (keyIndex < 0 || keyIndex >= mKeys.length)
        return;
    Key key = keys[keyIndex];
    if (key.icon != null) {
        mPreviewText.setCompoundDrawables(null, null, null, key.iconPreview != null ? key.iconPreview : key.icon);
        mPreviewText.setText(null);
    } else {
        mPreviewText.setCompoundDrawables(null, null, null, null);
        mPreviewText.setText(getPreviewText(key));
        if (key.label.length() > 1 && key.codes.length < 2) {
            mPreviewText.setTextSize(TypedValue.COMPLEX_UNIT_PX, mKeyTextSize);
            mPreviewText.setTypeface(Typeface.DEFAULT_BOLD);
        } else {
            mPreviewText.setTextSize(TypedValue.COMPLEX_UNIT_PX, mPreviewTextSizeLarge);
            mPreviewText.setTypeface(Typeface.DEFAULT);
        }
    }
    mPreviewText.measure(MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED), MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED));
    int popupWidth = Math.max(mPreviewText.getMeasuredWidth(), key.width + mPreviewText.getPaddingLeft() + mPreviewText.getPaddingRight());
    final int popupHeight = mPreviewHeight;
    LayoutParams lp = mPreviewText.getLayoutParams();
    if (lp != null) {
        lp.width = popupWidth;
        lp.height = popupHeight;
    }
    if (!mPreviewCentered) {
        mPopupPreviewX = key.x - mPreviewText.getPaddingLeft() + mPaddingLeft;
        mPopupPreviewY = key.y - popupHeight + mPreviewOffset;
    } else {
        // TODO: Fix this if centering is brought back
        mPopupPreviewX = 160 - mPreviewText.getMeasuredWidth() / 2;
        mPopupPreviewY = -mPreviewText.getMeasuredHeight();
    }
    mHandler.removeMessages(MSG_REMOVE_PREVIEW);
    getLocationInWindow(mCoordinates);
    // Offset may be zero
    mCoordinates[0] += mMiniKeyboardOffsetX;
    // Offset may be zero
    mCoordinates[1] += mMiniKeyboardOffsetY;
    // Set the preview background state
    mPreviewText.getBackground().setState(key.popupResId != 0 ? LONG_PRESSABLE_STATE_SET : EMPTY_STATE_SET);
    mPopupPreviewX += mCoordinates[0];
    mPopupPreviewY += mCoordinates[1];
    // If the popup cannot be shown above the key, put it on the side
    getLocationOnScreen(mCoordinates);
    if (mPopupPreviewY + mCoordinates[1] < 0) {
        // the right, offset by enough to see at least one key to the left/right.
        if (key.x + key.width <= getWidth() / 2) {
            mPopupPreviewX += (int) (key.width * 2.5);
        } else {
            mPopupPreviewX -= (int) (key.width * 2.5);
        }
        mPopupPreviewY += popupHeight;
    }
    if (previewPopup.isShowing()) {
        previewPopup.update(mPopupPreviewX, mPopupPreviewY, popupWidth, popupHeight);
    } else {
        previewPopup.setWidth(popupWidth);
        previewPopup.setHeight(popupHeight);
        previewPopup.showAtLocation(mPopupParent, Gravity.NO_GRAVITY, mPopupPreviewX, mPopupPreviewY);
    }
    mPreviewText.setVisibility(VISIBLE);
}
Also used : LayoutParams(android.view.ViewGroup.LayoutParams) PopupWindow(android.widget.PopupWindow) Key(android.inputmethodservice.Keyboard.Key) Paint(android.graphics.Paint)

Example 78 with LayoutParams

use of android.view.ViewGroup.LayoutParams in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class BluetoothSettings method resetBarSize.

private void resetBarSize(float titleTextSize, int actionBarHeight, int switchBarHeight) {
    Activity activity = getActivity();
    DisplayMetrics displayMetrics = Resources.getSystem().getDisplayMetrics();
    int titleId = Resources.getSystem().getIdentifier("action_bar", "id", "android");
    Toolbar toolbar = (Toolbar) activity.getWindow().findViewById(titleId);
    TextView title = null;
    if (toolbar != null) {
        LayoutParams layoutParams = toolbar.getLayoutParams();
        layoutParams.height = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, actionBarHeight, displayMetrics);
        for (int i = 0; i < toolbar.getChildCount(); ++i) {
            if (toolbar.getChildAt(i) instanceof TextView) {
                title = (TextView) toolbar.getChildAt(i);
            }
            Toolbar.LayoutParams childLayoutParams = (Toolbar.LayoutParams) toolbar.getChildAt(i).getLayoutParams();
            childLayoutParams.gravity = Gravity.CENTER_VERTICAL;
        }
    }
    if (title != null)
        title.setTextSize(TypedValue.COMPLEX_UNIT_DIP, titleTextSize);
    if (mSwitchBar != null) {
        LayoutParams layoutParams = mSwitchBar.getLayoutParams();
        layoutParams.height = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, switchBarHeight, displayMetrics);
    }
}
Also used : LayoutParams(android.view.ViewGroup.LayoutParams) SettingsActivity(com.android.settings.SettingsActivity) Activity(android.app.Activity) TextView(android.widget.TextView) DisplayMetrics(android.util.DisplayMetrics) Toolbar(android.widget.Toolbar)

Example 79 with LayoutParams

use of android.view.ViewGroup.LayoutParams in project android_frameworks_base by ResurrectionRemix.

the class Dialog method dispatchPopulateAccessibilityEvent.

@Override
public boolean dispatchPopulateAccessibilityEvent(@NonNull AccessibilityEvent event) {
    event.setClassName(getClass().getName());
    event.setPackageName(mContext.getPackageName());
    LayoutParams params = getWindow().getAttributes();
    boolean isFullScreen = (params.width == LayoutParams.MATCH_PARENT) && (params.height == LayoutParams.MATCH_PARENT);
    event.setFullScreen(isFullScreen);
    return false;
}
Also used : LayoutParams(android.view.ViewGroup.LayoutParams)

Example 80 with LayoutParams

use of android.view.ViewGroup.LayoutParams in project newsrob by marianokamp.

the class DashboardListActivity method initialize.

private void initialize(Intent i) {
    dbQuery = UIHelper.createDBQueryFromIntentExtras(getEntryManager(), i);
    Cursor c = getEntryManager().getDashboardContentCursor(dbQuery);
    startManagingCursor(c);
    final int readIndicator = getEntryManager().isLightColorSchemeSelected() ? R.drawable.read_indicator : R.drawable.read_indicator_dark;
    sca = new SimpleCursorAdapter(this, R.layout.dashboard_list_row, c, new String[] { "_id", "frequency", "sum_unread_freq" }, new int[] { R.id.item_title, R.id.item_count, R.id.unread });
    sca.setViewBinder(new SimpleCursorAdapter.ViewBinder() {

        public boolean setViewValue(View view, final Cursor cursor, int columnIndex) {
            if (columnIndex == 2) {
                TextView tv = (TextView) view;
                boolean containsUnread = cursor.getInt(2) > 0;
                tv.setBackgroundResource(containsUnread ? readIndicator : R.drawable.read_indicator_invisible);
                return true;
            } else if (columnIndex == 1) {
                final View itemCount = view;
                View.OnClickListener itemCountClickListener = new View.OnClickListener() {

                    @Override
                    public void onClick(View v) {
                        final String stringValueOfTag = v.getTag(R.id.view_position).toString();
                        final int position = Integer.valueOf(stringValueOfTag);
                        onListItemClick(getListView(), v, position, -99l);
                        final Drawable d = getResources().getDrawable(entryManager.isLightColorSchemeSelected() ? R.drawable.count_list_item : R.drawable.count_list_item_dark);
                        LayoutParams lp = v.getLayoutParams();
                        lp.height = v.getHeight();
                        v.setLayoutParams(lp);
                        v.setBackgroundDrawable(d);
                    }
                };
                view.setTag(R.id.view_position, cursor.getPosition());
                itemCount.setOnClickListener(itemCountClickListener);
            }
            return false;
        }
    });
    setListAdapter(sca);
    if (!getEntryManager().isLicenseAccepted())
        showDialog(DIALOG_SHOW_LICENSE);
    else {
        if (getEntryManager().getDaysInstalled() >= 3 && getEntryManager().shouldAskForUsageDataCollectionPermission())
            showDialog(DIALOG_SHOW_USAGE_DATA_COLLECTION);
        // Skip this activity when now labels are displayed
        if (sca.getCount() == 1 && i.getBooleanExtra("skip", true)) {
            Intent intent = new Intent(this, FeedListActivity.class);
            UIHelper.addExtrasFromDBQuery(intent, dbQuery);
            startActivity(intent);
            if (!isTaskRoot())
                finish();
        }
    }
}
Also used : LayoutParams(android.view.ViewGroup.LayoutParams) SimpleCursorAdapter(android.widget.SimpleCursorAdapter) Drawable(android.graphics.drawable.Drawable) TextView(android.widget.TextView) Intent(android.content.Intent) Cursor(android.database.Cursor) TextView(android.widget.TextView) View(android.view.View) ListView(android.widget.ListView)

Aggregations

LayoutParams (android.view.ViewGroup.LayoutParams)265 TextView (android.widget.TextView)56 View (android.view.View)50 ViewGroup (android.view.ViewGroup)50 FrameLayout (android.widget.FrameLayout)35 LinearLayout (android.widget.LinearLayout)33 ImageView (android.widget.ImageView)30 Test (org.junit.Test)26 Paint (android.graphics.Paint)22 ListView (android.widget.ListView)22 ScrollView (android.widget.ScrollView)22 Context (android.content.Context)19 MarginLayoutParams (android.view.ViewGroup.MarginLayoutParams)19 AdapterView (android.widget.AdapterView)17 RelativeLayout (android.widget.RelativeLayout)14 DisplayMetrics (android.util.DisplayMetrics)12 CheckedTextView (android.widget.CheckedTextView)12 Rect (android.graphics.Rect)9 ViewParent (android.view.ViewParent)9 TypedArray (android.content.res.TypedArray)8