private void addDivider(boolean iOSStylable) { ImageView divider = new ImageView(mContext); divider.setScaleType(ScaleType.FIT_XY); divider.setBackgroundColor(getResources().getColor(R.color.setting_view_item_bg_normal)); divider.setImageResource(R.drawable.divider); LayoutParams lps = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT); lps.gravity = Gravity.RIGHT; if (iOSStyleable) { int paddingLeft = (int) TypedValue.applyDimension( TypedValue.COMPLEX_UNIT_PX, getResources().getDimensionPixelSize(R.dimen.setting_view_min_height), getResources().getDisplayMetrics()) + (int) TypedValue.applyDimension( TypedValue.COMPLEX_UNIT_PX, getResources().getDimensionPixelSize(R.dimen.setting_view_lr_padding), getResources().getDisplayMetrics()); divider.setPadding(paddingLeft, 0, 0, 0); } addView(divider, lps); }
/** * 获取自定义属性 * * @param attrs */ private void obtainStyledAttributes(AttributeSet attrs) { metrics = getContext().getResources().getDisplayMetrics(); framePadding = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, DEFAULT_FRAME_PADDING, metrics); frameWidth = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, DEFAULT_FRAME_WIDTH, metrics); TypedArray mTypedArray = getContext().obtainStyledAttributes(attrs, R.styleable.WaterMarkView); Drawable srcDrawble = mTypedArray.getDrawable(R.styleable.WaterMarkView_src); if (srcDrawble instanceof BitmapDrawable) { BitmapDrawable bd = (BitmapDrawable) srcDrawble; this.mWaterMarkBitmap = bd.getBitmap(); } framePadding = mTypedArray.getDimensionPixelSize(R.styleable.WaterMarkView_framePadding, framePadding); frameWidth = mTypedArray.getDimensionPixelSize(R.styleable.WaterMarkView_frameWidth, frameWidth); frameColor = mTypedArray.getColor(R.styleable.WaterMarkView_frameColor, DEFAULT_FRAME_COLOR); mScale = mTypedArray.getFloat(R.styleable.WaterMarkView_scale, DEFAULT_SCALE); mDegree = mTypedArray.getFloat(R.styleable.WaterMarkView_degree, DEFAULT_DEGREE); controlDrawable = mTypedArray.getDrawable(R.styleable.WaterMarkView_controlDrawable); controlLocation = mTypedArray.getInt(R.styleable.WaterMarkView_controlLocation, DEFAULT_CONTROL_LOCATION); isEditable = mTypedArray.getBoolean(R.styleable.WaterMarkView_editable, DEFAULT_EDITABLE); mTypedArray.recycle(); }
@Override protected void onCreate(final Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.list_view); ListView listView = (ListView) findViewById(R.id.list_view); mGoogleCardsAdapter = new GoogleCardsSocialAdapter(this, DummyContent.getDummyModelList()); SwingBottomInAnimationAdapter swingBottomInAnimationAdapter = new SwingBottomInAnimationAdapter(new SwipeDismissAdapter(mGoogleCardsAdapter, this)); swingBottomInAnimationAdapter.setAbsListView(listView); assert swingBottomInAnimationAdapter.getViewAnimator() != null; swingBottomInAnimationAdapter.getViewAnimator().setInitialDelayMillis(INITIAL_DELAY_MILLIS); listView.setClipToPadding(false); listView.setDivider(null); Resources r = getResources(); int px = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 8, r.getDisplayMetrics()); listView.setDividerHeight(px); listView.setFadingEdgeLength(0); listView.setFitsSystemWindows(true); px = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 12, r.getDisplayMetrics()); listView.setPadding(px, px, px, px); listView.setScrollBarStyle(ListView.SCROLLBARS_OUTSIDE_OVERLAY); listView.setAdapter(swingBottomInAnimationAdapter); getSupportActionBar().setDisplayHomeAsUpEnabled(true); getSupportActionBar().setTitle("Google cards social"); }
private void addHeader() { TableRow rowHeader = new TableRow(getActivity().getBaseContext()); TextView lblNim = new TextView(getActivity().getBaseContext()), lblNama = new TextView(getActivity().getBaseContext()); lblNim.setText("NIM"); lblNama.setText("Nama"); Float pixel1 = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 120, r.getDisplayMetrics()); Float pixel2 = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 260, r.getDisplayMetrics()); lblNim.setGravity(Gravity.CENTER_HORIZONTAL); lblNama.setGravity(Gravity.CENTER_HORIZONTAL); TableRow.LayoutParams param = new TableRow.LayoutParams(0, TableRow.LayoutParams.WRAP_CONTENT, 1f); lblNama.setLayoutParams(param); lblNim.setLayoutParams(param); lblNim.setWidth(Math.round(pixel1)); lblNama.setWidth(Math.round(pixel2)); lblNim.setTextColor(Color.BLACK); lblNama.setTextColor(Color.BLACK); rowHeader.addView(lblNim); rowHeader.addView(lblNama); tblDaftarMhs.addView(rowHeader); }
/** * Calls the super() method to give us our surfaceView to work with Link the class up with the * SurfaceHolder.Callback Initialize variables regarding the circle Set the speed of mouvement in * each direction * * @param context */ public AnimationView(Context context) { super(context); getHolder().addCallback(this); getHolder().setKeepScreenOn(true); // float px = 30F; // DisplayMetrics metrics = getResources().getDisplayMetrics(); // float dp = px / (metrics.densityDpi / 160f); circleRadius = TypedValue.applyDimension( TypedValue.COMPLEX_UNIT_DIP, 30, getResources().getDisplayMetrics()); circlePaint = new Paint(); circlePaint.setColor(Color.RED); circlePaint.setAntiAlias(true); float textSize = TypedValue.applyDimension( TypedValue.COMPLEX_UNIT_DIP, 30, getResources().getDisplayMetrics()); timePaint = new Paint(); timePaint.setColor(getResources().getColor(R.color.ColorPrimaryDark)); timePaint.setTextAlign(Paint.Align.CENTER); timePaint.setTextSize(textSize); timePaint.setAntiAlias(true); vx = 2; vy = 2; }
private void initView(Context context, AttributeSet attrs, int defStyleAttr) { PULL_HEIGHT = (int) TypedValue.applyDimension( TypedValue.COMPLEX_UNIT_DIP, 100, context.getResources().getDisplayMetrics()); PULL_DELTA = (int) TypedValue.applyDimension( TypedValue.COMPLEX_UNIT_DIP, 50, context.getResources().getDisplayMetrics()); mWidthOffset = 0.5f; mBackPaint = new Paint(); mBackPaint.setAntiAlias(true); mBackPaint.setStyle(Paint.Style.FILL); mBackPaint.setColor(0xff8b90af); mBallPaint = new Paint(); mBallPaint.setAntiAlias(true); mBallPaint.setColor(0xffffffff); mBallPaint.setStyle(Paint.Style.FILL); mOutPaint = new Paint(); mOutPaint.setAntiAlias(true); mOutPaint.setColor(0xffffffff); mOutPaint.setStyle(Paint.Style.STROKE); mOutPaint.setStrokeWidth(5); mPath = new Path(); }
private void init(AttributeSet attrs) { setOrientation(VERTICAL); mData = new ArrayList<>(); mRows = new ArrayList<>(); DisplayMetrics dm = getResources().getDisplayMetrics(); mItemMargin = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, DEFAULT_ITEM_MARGIN, dm); mTextSize = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_SP, DEFAULT_TEXT_SIZE, dm); mTextColor = DEFAULT_TEXT_COLOR; mPaddingHor = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, DEFAULT_ITEM_PADDING_HOR, dm); mPaddingVer = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, DEFAULT_ITEM_PADDING_VER, dm); mRowSpacing = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, DEFAULT_ROW_SPACING, dm); // get custom attrs TypedArray a = mContext.obtainStyledAttributes(attrs, R.styleable.SingleChoiceItemsView); mTextSize = a.getDimensionPixelSize(R.styleable.SingleChoiceItemsView_sciItemTextSize, mTextSize); mTextColor = a.getColor(R.styleable.SingleChoiceItemsView_sciItemTextColor, mTextColor); mItemBgResourceId = a.getResourceId(R.styleable.SingleChoiceItemsView_sciItemBackground, DEFAULT_ITEM_BG); mItemMargin = a.getDimensionPixelSize(R.styleable.SingleChoiceItemsView_sciItemMargin, mItemMargin); a.recycle(); }
public View onCreateView( LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { FrameLayout.LayoutParams params = new FrameLayout.LayoutParams( FrameLayout.LayoutParams.MATCH_PARENT, FrameLayout.LayoutParams.MATCH_PARENT); FrameLayout fl = new FrameLayout(getActivity()); fl.setLayoutParams(params); DisplayMetrics dm = getResources().getDisplayMetrics(); final int margin = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 8, dm); TextView v = new TextView(getActivity()); params.setMargins(margin, margin, margin, margin); v.setLayoutParams(params); v.setLayoutParams(params); v.setGravity(Gravity.CENTER); v.setText("PAGE09 "); v.setTextSize((int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_SP, 12, dm)); // WebView webviewtest= new WebView(getActivity()); // webviewtest.loadUrl("file:///android_asset/1.html"); // fl.addView(webviewtest); fl.addView(v); return fl; }
private Point cY(int i) { Point point; int j; byte byte0; byte0 = 24; j = 20; point = new Point(); i; JVM INSTR tableswitch 0 2: default 44 // 0 112 // 1 106 // 2 122; goto _L1 _L2 _L3 _L4 _L1: i = 38; j = 24; _L6: android.util.DisplayMetrics displaymetrics = getResources().getDisplayMetrics(); float f = TypedValue.applyDimension(1, i, displaymetrics); float f1 = TypedValue.applyDimension(1, j, displaymetrics); point.x = (int)((double)f + 0.5D); point.y = (int)((double)f1 + 0.5D); return point; _L3: i = 32; continue; /* Loop/switch isn't completed */ _L2: j = 14; i = byte0; continue; /* Loop/switch isn't completed */ _L4: i = 50; if (true) goto _L6; else goto _L5
public CropImageView(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); mFocusWidth = (int) TypedValue.applyDimension( TypedValue.COMPLEX_UNIT_DIP, mFocusWidth, getResources().getDisplayMetrics()); mFocusHeight = (int) TypedValue.applyDimension( TypedValue.COMPLEX_UNIT_DIP, mFocusHeight, getResources().getDisplayMetrics()); mBorderWidth = (int) TypedValue.applyDimension( TypedValue.COMPLEX_UNIT_DIP, mBorderWidth, getResources().getDisplayMetrics()); TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.CropImageView); mMaskColor = a.getColor(R.styleable.CropImageView_cropMaskColor, mMaskColor); mBorderColor = a.getColor(R.styleable.CropImageView_cropBorderColor, mBorderColor); mBorderWidth = a.getDimensionPixelSize(R.styleable.CropImageView_cropBorderWidth, mBorderWidth); mFocusWidth = a.getDimensionPixelSize(R.styleable.CropImageView_cropFocusWidth, mFocusWidth); mFocusHeight = a.getDimensionPixelSize(R.styleable.CropImageView_cropFocusHeight, mFocusHeight); mDefaultStyleIndex = a.getInteger(R.styleable.CropImageView_cropStyle, mDefaultStyleIndex); mStyle = styles[mDefaultStyleIndex]; a.recycle(); // 只允许图片为当前的缩放模式 setScaleType(ScaleType.MATRIX); }
Description parseValue(TypedValue value) { Description d = new Description(); if (value == null) { d.type = ABSOLUTE; d.value = 0; } else { if (value.type == TypedValue.TYPE_FRACTION) { d.type = (value.data & TypedValue.COMPLEX_UNIT_MASK) == TypedValue.COMPLEX_UNIT_FRACTION_PARENT ? RELATIVE_TO_PARENT : RELATIVE_TO_SELF; d.value = TypedValue.complexToFloat(value.data); return d; } else if (value.type == TypedValue.TYPE_FLOAT) { d.type = ABSOLUTE; d.value = value.getFloat(); return d; } else if (value.type >= TypedValue.TYPE_FIRST_INT && value.type <= TypedValue.TYPE_LAST_INT) { d.type = ABSOLUTE; d.value = value.data; return d; } } d.type = ABSOLUTE; d.value = 0.0f; return d; }
private void init(Context context) { DisplayMetrics displayMetrics = context.getResources().getDisplayMetrics(); mHandleRadius = HandleUtil.getTargetRadius(context); mSnapRadius = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, SNAP_RADIUS_DP, displayMetrics); mBorderPaint = PaintUtil.newBorderPaint(context); mGuidelinePaint = PaintUtil.newGuidelinePaint(); mBackgroundPaint = PaintUtil.newBackgroundPaint(context); mCornerPaint = PaintUtil.newCornerPaint(context); // Sets the values for the corner sizes mCornerOffset = TypedValue.applyDimension( TypedValue.COMPLEX_UNIT_DIP, DEFAULT_CORNER_OFFSET_DP, displayMetrics); mCornerExtension = TypedValue.applyDimension( TypedValue.COMPLEX_UNIT_DIP, DEFAULT_CORNER_EXTENSION_DP, displayMetrics); mCornerLength = TypedValue.applyDimension( TypedValue.COMPLEX_UNIT_DIP, DEFAULT_CORNER_LENGTH_DP, displayMetrics); // Sets guidelines to default until specified otherwise mGuidelines = CropImageView.DEFAULT_GUIDELINES; }
/** * Parse the attributes passed to the view from the XML * * @param a the attributes to parse */ private void parseAttributes(TypedArray a) { // We transform the default values from DIP to pixels DisplayMetrics metrics = getContext().getResources().getDisplayMetrics(); barWidth = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, barWidth, metrics); rimWidth = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, rimWidth, metrics); circleRadius = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, circleRadius, metrics); circleRadius = (int) a.getDimension(R.styleable.ProgressWheel_matProg_circleRadius, circleRadius); fillRadius = a.getBoolean(R.styleable.ProgressWheel_matProg_fillRadius, false); barWidth = (int) a.getDimension(R.styleable.ProgressWheel_matProg_barWidth, barWidth); rimWidth = (int) a.getDimension(R.styleable.ProgressWheel_matProg_rimWidth, rimWidth); float baseSpinSpeed = a.getFloat(R.styleable.ProgressWheel_matProg_spinSpeed, spinSpeed / 360.0f); spinSpeed = baseSpinSpeed * 360; barSpinCycleTime = a.getInt(R.styleable.ProgressWheel_matProg_barSpinCycleTime, (int) barSpinCycleTime); barColor = a.getColor(R.styleable.ProgressWheel_matProg_barColor, barColor); rimColor = a.getColor(R.styleable.ProgressWheel_matProg_rimColor, rimColor); linearProgress = a.getBoolean(R.styleable.ProgressWheel_matProg_linearProgress, false); if (a.getBoolean(R.styleable.ProgressWheel_matProg_progressIndeterminate, false)) { spin(); } // Recycle a.recycle(); }
private void fillUI() { // add logic in order not to set twice values, loader get's called twice. Picasso.with(getContext()).load(mMovie.getPosterUri()).into(mImageView); mTitle.setText(mMovie.getTitle()); mDate.setText(mMovie.getReleaseDate().trim().substring(0, 4)); if (mMovie.getVoteAverage() != null) mVote.setText(String.valueOf(mMovie.getVoteAverage()) + "/10"); mPlot.setText(mMovie.getOverview()); if (!(mReviews == null || mReviews.isEmpty())) { for (Reviews.Result review : mReviews) { TextView textView = new TextView(getContext()); textView.setLayoutParams( new LinearLayout.LayoutParams( ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT)); textView.setText( getResources().getString(R.string.icon_video) + "\n" + review.getContent()); textView.setTypeface(mFont); textView.setPadding(2, 2, 2, 2); // textView.setTextAppearance(R.s); mReviewsll.addView(textView); } } if (!(mVideos == null || mVideos.isEmpty())) { for (final Videos.Result video : mVideos) { Button button = new Button(getActivity()); button.setLayoutParams( new ViewGroup.LayoutParams( ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT)); button.setText(getResources().getString(R.string.icon_youtube)); button.setTypeface(mFont); button.setOnClickListener( new View.OnClickListener() { @Override public void onClick(View v) { if (mVideos != null) { startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(video.getUri()))); } } }); button.setPadding(2, 2, 2, 2); mTrailersll.addView(button); } } Log.d(LOG_TAG, getActivity().getLocalClassName().trim()); if (getActivity().getLocalClassName().equalsIgnoreCase("DetailActivity")) { Log.d(LOG_TAG, "insidePhone"); Resources r = getResources(); float width = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 185, r.getDisplayMetrics()); float height = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 262, r.getDisplayMetrics()); mImageView.setLayoutParams( new LinearLayout.LayoutParams(new ViewGroup.LayoutParams((int) width, (int) height))); } }
@Override public boolean fillTypedValue(FsFile data, TypedValue typedValue) { typedValue.type = TypedValue.TYPE_STRING; typedValue.data = 0; typedValue.string = data.getPath(); typedValue.assetCookie = getNextStringCookie(); return true; }
public ShSwitchView(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); TypedArray ta = context.obtainStyledAttributes(attrs, R.styleable.ShSwitchView); tintColor = ta.getColor(R.styleable.ShSwitchView_tintColor, 0xFF9CE949); tempTintColor = tintColor; int defaultOuterStrokeWidth = (int) TypedValue.applyDimension( TypedValue.COMPLEX_UNIT_DIP, 1.5F, context.getResources().getDisplayMetrics()); int defaultShadowSpace = (int) TypedValue.applyDimension( TypedValue.COMPLEX_UNIT_DIP, 5, context.getResources().getDisplayMetrics()); outerStrokeWidth = ta.getDimensionPixelOffset( R.styleable.ShSwitchView_outerStrokeWidth, defaultOuterStrokeWidth); shadowSpace = ta.getDimensionPixelOffset(R.styleable.ShSwitchView_shadowSpace, defaultShadowSpace); ta.recycle(); knobBound = new RectF(); innerContentBound = new RectF(); ovalForPath = new RectF(); tempForRoundRect = new RectF(); paint = new Paint(Paint.ANTI_ALIAS_FLAG); roundRectPath = new Path(); gestureDetector = new GestureDetector(context, gestureListener); gestureDetector.setIsLongpressEnabled(false); if (Build.VERSION.SDK_INT >= 11) { setLayerType(View.LAYER_TYPE_SOFTWARE, null); } innerContentAnimator = ObjectAnimator.ofFloat(ShSwitchView.this, innerContentProperty, innerContentRate, 1.0F); innerContentAnimator.setDuration(commonDuration); innerContentAnimator.setInterpolator(new DecelerateInterpolator()); knobExpandAnimator = ObjectAnimator.ofFloat(ShSwitchView.this, knobExpandProperty, knobExpandRate, 1.0F); knobExpandAnimator.setDuration(commonDuration); knobExpandAnimator.setInterpolator(new DecelerateInterpolator()); knobMoveAnimator = ObjectAnimator.ofFloat(ShSwitchView.this, knobMoveProperty, knobMoveRate, 1.0F); knobMoveAnimator.setDuration(commonDuration); knobMoveAnimator.setInterpolator(new DecelerateInterpolator()); shadowDrawable = context.getResources().getDrawable(R.drawable.shadow); }
private void setTabsValue() { tabs.setShouldExpand(true); tabs.setDividerColor(Color.TRANSPARENT); tabs.setUnderlineHeight((int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 1, dm)); tabs.setIndicatorHeight((int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 4, dm)); tabs.setTextSize((int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 16, dm)); tabs.setIndicatorColor(Color.parseColor("#45c01a")); tabs.setTabBackground(0); }
public static boolean resolveAttribute(int attrId, TypedValue outValue) { if (currentInstance == null) return false; SparseIntArray customAttrs = currentInstance.customAttrs; int index = customAttrs.indexOfKey(attrId); if (index < 0) return false; outValue.type = TypedValue.TYPE_INT_COLOR_ARGB8; outValue.data = customAttrs.valueAt(index); return true; }
@Override public boolean fillTypedValue(String data, TypedValue typedValue) { try { typedValue.type = TypedValue.TYPE_INT_HEX; typedValue.data = findValueFor(data); typedValue.assetCookie = 0; return true; } catch (Exception e) { return false; } }
@Override public boolean fillTypedValue(String data, TypedValue typedValue) { try { typedValue.type = TypedValue.TYPE_INT_HEX; typedValue.data = convertInt(data); typedValue.assetCookie = 0; return true; } catch (NumberFormatException nfe) { return false; } }
@Override public boolean fillTypedValue(String data, TypedValue typedValue) { try { typedValue.type = TypedValue.TYPE_INT_COLOR_ARGB8; typedValue.data = ResourceHelper.getColor(data); typedValue.assetCookie = 0; return true; } catch (NumberFormatException nfe) { return false; } }
public SimpleListItemView setIsChildItem() { float px20 = TypedValue.applyDimension( TypedValue.COMPLEX_UNIT_DIP, 20, getResources().getDisplayMetrics()); float px10 = TypedValue.applyDimension( TypedValue.COMPLEX_UNIT_DIP, -10, getResources().getDisplayMetrics()); LayoutParams params = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT); params.setMargins(Math.round(px20), Math.round(px10), Math.round(px20), Math.round(px10)); rootLayout.setLayoutParams(params); return this; }
/** 检查是否处于透明背景状态 */ private void checkRightSlidingFinishActivity() { /** 解析是否可以使用右滑 finish activity功能 */ if (!this.ignoreRightSlidingFinishActivity) { String windowIsTranslucent, windowBackground; TypedValue outValue = new TypedValue(); getTheme().resolveAttribute(android.R.attr.windowIsTranslucent, outValue, true); windowIsTranslucent = String.valueOf(outValue.coerceToString()); getTheme().resolveAttribute(android.R.attr.windowBackground, outValue, true); windowBackground = String.valueOf(outValue.coerceToString()); this.ignoreRightSlidingFinishActivity = !("true".equals(windowIsTranslucent) && "#0".equals(windowBackground)); } }
private float getVerticalScrollFactorCompat() { if (this.mVerticalScrollFactor == 0.0F) { TypedValue var1 = new TypedValue(); Context var2 = this.getContext(); if (!var2.getTheme().resolveAttribute(16842829, var1, true)) { throw new IllegalStateException("Expected theme to define listPreferredItemHeight."); } this.mVerticalScrollFactor = var1.getDimension(var2.getResources().getDisplayMetrics()); } return this.mVerticalScrollFactor; }
private void setTabsValue() { dm = getResources().getDisplayMetrics(); mPagerSlidingTabStrip.setDividerColor(Color.TRANSPARENT); mPagerSlidingTabStrip.setUnderlineHeight( (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 1, dm)); mPagerSlidingTabStrip.setIndicatorHeight( (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 4, dm)); mPagerSlidingTabStrip.setTextSize( (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_SP, 12, dm)); mPagerSlidingTabStrip.setIndicatorColor(Color.parseColor("#45c01a")); mPagerSlidingTabStrip.setTabBackground(0); }
/** * Retrieve the string value associated with a particular resource identifier for the current * configuration / skin. */ /*package*/ final CharSequence getResourceBagText(int ident, int bagEntryId) { synchronized (this) { TypedValue tmpValue = mValue; int block = loadResourceBagValue(ident, bagEntryId, tmpValue, true); if (block >= 0) { if (tmpValue.type == TypedValue.TYPE_STRING) { return mStringBlocks[block].get(tmpValue.data); } return tmpValue.coerceToString(); } } return null; }
public void bannerAdView() { MMAdView adView = new MMAdView(this); // Replace YOUR_APID with the APID provided to you by Millennial Media adView.setApid("163762"); // Set your metadata in the MMRequest object MMRequest request = new MMRequest(); // Set available metadata here. IE: age, children, education, etc request.setAge("20"); request.setEducation(MMRequest.EDUCATION_HIGH_SCHOOL); // Add the MMRequest object to your MMAdView. adView.setMMRequest(request); // Sets the id to preserve your ad on configuration changes. adView.setId(MMSDK.getDefaultAdId()); // Set the ad size. Replace the width and height values if needed. adView.setWidth(placementWidth); adView.setHeight(placementHeight); // Calculate the size of the adView based on the ad size. Replace the width and height values if // needed. int layoutWidth = (int) TypedValue.applyDimension( TypedValue.COMPLEX_UNIT_DIP, placementWidth, getResources().getDisplayMetrics()); int layoutHeight = (int) TypedValue.applyDimension( TypedValue.COMPLEX_UNIT_DIP, placementHeight, getResources().getDisplayMetrics()); // Create the layout parameters using the calculated adView width and height. RelativeLayout.LayoutParams layoutParams = new RelativeLayout.LayoutParams(layoutWidth, layoutHeight); // This positions the banner. layoutParams.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM); layoutParams.addRule(RelativeLayout.CENTER_HORIZONTAL); adView.setLayoutParams(layoutParams); // Add the adView to the layout. The layout is assumed to be a RelativeLayout. RelativeLayout layout = (RelativeLayout) findViewById(R.id.relayout); layout.addView(adView); adView.getAd(); adIsLive = true; }
public ShadowView(Context context, AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); TypedArray a = context.getTheme().obtainStyledAttributes(attrs, R.styleable.ShadowView, defStyleAttr, 0); int n = a.getIndexCount(); for (int i = 0; i < n; i++) { int attr = a.getIndex(i); switch (attr) { case R.styleable.ShadowView_sv_text: text = a.getString(attr); break; case R.styleable.ShadowView_sv_textColor: textColor = a.getColor(attr, Color.BLACK); break; case R.styleable.ShadowView_sv_textSize: textSize = a.getDimensionPixelSize( attr, (int) TypedValue.applyDimension( TypedValue.COMPLEX_UNIT_SP, 16, getResources().getDisplayMetrics())); break; case R.styleable.ShadowView_sv_shadowColor: shadowColor = a.getColor(attr, Color.BLACK); break; case R.styleable.ShadowView_sv_shadowSize: shadowSize = a.getDimensionPixelSize( attr, (int) TypedValue.applyDimension( TypedValue.COMPLEX_UNIT_DIP, 0, getResources().getDisplayMetrics())); break; case R.styleable.ShadowView_sv_direction: shadowDirection = a.getInt(attr, RIGHTBOTTOM); break; } } a.recycle(); paint = new Paint(); paint.setTextSize(textSize); paint.setFakeBoldText(true); paint.setColor(textColor); textBound = new Rect(); paint.getTextBounds(text, 0, text.length(), textBound); calcShadow(); }
private void parseXmlSettings(Context context, AttributeSet attrs, float density) { // parse "android:text" String textValue = attrs.getAttributeValue("http://schemas.android.com/apk/res/android", "text"); if (null == textValue) { originalText = ""; } else { if (textValue.startsWith("@")) { originalText = context.getString(Integer.valueOf(textValue.replace("@", ""))); } else { originalText = textValue; } } // parse "android:textSize" String textSizeValue = attrs.getAttributeValue("http://schemas.android.com/apk/res/android", "textSize"); float defaultTextSize = DEFAULT_TEXT_SIZE_DIPS * density; if (null == textSizeValue) { setTextSize(defaultTextSize); } else { if (textSizeValue.endsWith("dip")) { setTextSize( TypedValue.applyDimension( TypedValue.COMPLEX_UNIT_DIP, Float.valueOf(textSizeValue.replace("dip", "")), getResources().getDisplayMetrics())); } else if (textSizeValue.endsWith("sp")) { setTextSize( TypedValue.applyDimension( TypedValue.COMPLEX_UNIT_SP, Float.valueOf(textSizeValue.replace("sp", "")), getResources().getDisplayMetrics())); } } // parse "android:textColor" String textColorValue = attrs.getAttributeValue("http://schemas.android.com/apk/res/android", "textColor"); if (null != textColorValue) { if (textColorValue.startsWith("@")) { setTextColor( context.getResources().getColor(Integer.valueOf(textColorValue.replace("@", "")))); } else if (textColorValue.startsWith("#")) { setTextColor(Color.parseColor(textColorValue)); } } }
@Override public View onCreateView( LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { if (container == null) { // We have different layouts, and in one of them this // fragment's containing frame doesn't exist. The fragment // may still be created from its saved state, but there is // no reason to try to create its view hierarchy because it // won't be displayed. Note this is not needed -- we could // just run the code below, where we would create and return // the view hierarchy; it would just never be used. return null; } ScrollView scroller = new ScrollView(getActivity()); TextView text = new TextView(getActivity()); int padding = (int) TypedValue.applyDimension( TypedValue.COMPLEX_UNIT_DIP, 4, getActivity().getResources().getDisplayMetrics()); text.setPadding(padding, padding, padding, padding); scroller.addView(text); text.setText(Shakespeare.DIALOGUE[getShownIndex()]); return scroller; }