當前位置: 首頁>>代碼示例>>Java>>正文


Java InsetDrawable類代碼示例

本文整理匯總了Java中android.graphics.drawable.InsetDrawable的典型用法代碼示例。如果您正苦於以下問題:Java InsetDrawable類的具體用法?Java InsetDrawable怎麽用?Java InsetDrawable使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


InsetDrawable類屬於android.graphics.drawable包,在下文中一共展示了InsetDrawable類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: containsNinePatch

import android.graphics.drawable.InsetDrawable; //導入依賴的package包/類
public static boolean containsNinePatch(Drawable drawable) {
    drawable = getWrapperDrawable(drawable);
    if (drawable instanceof NinePatchDrawable
            || drawable instanceof InsetDrawable
            || drawable instanceof LayerDrawable) {
        return true;
    } else if (drawable instanceof StateListDrawable) {
        final DrawableContainer.DrawableContainerState containerState = ((DrawableContainer.DrawableContainerState) drawable.getConstantState());
        //can't getBaseApplication containState from drawable which is containing DrawableWrapperDonut
        //https://code.google.com/p/android/issues/detail?id=169920
        if (containerState == null) {
            return true;
        }
        for (Drawable dr : containerState.getChildren()) {
            dr = getWrapperDrawable(dr);
            if (dr instanceof NinePatchDrawable
                    || dr instanceof InsetDrawable
                    || dr instanceof LayerDrawable) {
                return true;
            }
        }
    }
    return false;
}
 
開發者ID:Pingsh,項目名稱:Mix,代碼行數:25,代碼來源:ThemeUtils.java

示例2: onCreateView

import android.graphics.drawable.InsetDrawable; //導入依賴的package包/類
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
	final Context context = inflater.getContext();
       final Resources res = context.getResources();
	final View view = inflater.inflate(R.layout.fragment_directory, container, false);

       mProgressBar = (MaterialProgressBar) view.findViewById(R.id.progressBar);

	mEmptyView = (CompatTextView)view.findViewById(android.R.id.empty);

	mListView = (ListView) view.findViewById(R.id.list);
	mListView.setOnItemClickListener(mItemListener);
	mListView.setMultiChoiceModeListener(mMultiListener);
	mListView.setRecyclerListener(mRecycleListener);

       // Indent our list divider to align with text
       final Drawable divider = mListView.getDivider();
       final boolean insetLeft = res.getBoolean(R.bool.list_divider_inset_left);
       final int insetSize = res.getDimensionPixelSize(R.dimen.list_divider_inset);
       if (insetLeft) {
           mListView.setDivider(new InsetDrawable(divider, insetSize, 0, 0, 0));
       } else {
           mListView.setDivider(new InsetDrawable(divider, 0, 0, insetSize, 0));
       }

	mGridView = (GridView) view.findViewById(R.id.grid);
	mGridView.setOnItemClickListener(mItemListener);
	mGridView.setMultiChoiceModeListener(mMultiListener);
	mGridView.setRecyclerListener(mRecycleListener);

	return view;
}
 
開發者ID:gigabytedevelopers,項目名稱:FireFiles,代碼行數:33,代碼來源:DirectoryFragment.java

示例3: containsNinePatch

import android.graphics.drawable.InsetDrawable; //導入依賴的package包/類
public static boolean containsNinePatch(Drawable drawable) {
    drawable = getWrapperDrawable(drawable);
    if (drawable instanceof NinePatchDrawable
            || drawable instanceof InsetDrawable
            || drawable instanceof LayerDrawable) {
        return true;
    } else if (drawable instanceof StateListDrawable) {
        final DrawableContainer.DrawableContainerState containerState = ((DrawableContainer.DrawableContainerState) drawable.getConstantState());
        //can't get containState from drawable which is containing DrawableWrapperDonut
        //https://code.google.com/p/android/issues/detail?id=169920
        if (containerState == null) {
            return true;
        }
        for (Drawable dr : containerState.getChildren()) {
            dr = getWrapperDrawable(dr);
            if (dr instanceof NinePatchDrawable
                    || dr instanceof InsetDrawable
                    || dr instanceof LayerDrawable) {
                return true;
            }
        }
    }
    return false;
}
 
開發者ID:Bilibili,項目名稱:MagicaSakura,代碼行數:25,代碼來源:ThemeUtils.java

示例4: onUpdateBackgroundAndPaddings

import android.graphics.drawable.InsetDrawable; //導入依賴的package包/類
@Override
protected void onUpdateBackgroundAndPaddings(Rect searchBarBounds, Rect padding) {
    // Apply the top-bottom padding to the content itself so that the launcher transition is
    // clipped correctly
    mContent.setPadding(0, padding.top, 0, padding.bottom);

    // TODO: Use quantum_panel_dark instead of quantum_panel_shape_dark.
    InsetDrawable background = new InsetDrawable(
            getResources().getDrawable(R.drawable.quantum_panel_shape_dark), padding.left, 0,
            padding.right, 0);
    Rect bgPadding = new Rect();
    background.getPadding(bgPadding);
    mView.setBackground(background);
    getRevealView().setBackground(background.getConstantState().newDrawable());
    mView.updateBackgroundPadding(bgPadding);
}
 
開發者ID:Mr-lin930819,項目名稱:SimplOS,代碼行數:17,代碼來源:WidgetsContainerView.java

示例5: createButtonShape

import android.graphics.drawable.InsetDrawable; //導入依賴的package包/類
private static Drawable createButtonShape(Context context, int color) {
    // Translation of Lollipop's xml button-bg definition to Java
    int paddingH = DensityUtil.dip2px(context, 8);
    int paddingV = DensityUtil.dip2px(context, 4);
    int insetH = DensityUtil.dip2px(context, 4);
    int insetV = DensityUtil.dip2px(context, 6);
    int corner_radius = DensityUtil.dip2px(context, 2);
    float[] outerRadii = new float[8];
    Arrays.fill(outerRadii, corner_radius);

    RoundRectShape r = new RoundRectShape(outerRadii, null, null);

    ShapeDrawable shapeDrawable = new ShapeDrawable(r);
    shapeDrawable.getPaint().setColor(color);
    shapeDrawable.setPadding(paddingH, paddingV, paddingH, paddingV);

    return new InsetDrawable(shapeDrawable,
            insetH, insetV, insetH, insetV);
}
 
開發者ID:teambition,項目名稱:TbRepeatPicker,代碼行數:20,代碼來源:SUtils.java

示例6: shouldMutateBackground

import android.graphics.drawable.InsetDrawable; //導入依賴的package包/類
private static boolean shouldMutateBackground(Drawable drawable) {
    if (Build.VERSION.SDK_INT >= 16) {
        // For SDK 16+, we should be fine mutating the drawable
        return true;
    }

    if (drawable instanceof LayerDrawable) {
        return Build.VERSION.SDK_INT >= 16;
    } else if (drawable instanceof InsetDrawable) {
        return Build.VERSION.SDK_INT >= 14;
    } else if (drawable instanceof DrawableContainer) {
        // If we have a DrawableContainer, let's traverse it's child array
        final Drawable.ConstantState state = drawable.getConstantState();
        if (state instanceof DrawableContainer.DrawableContainerState) {
            final DrawableContainer.DrawableContainerState containerState =
                    (DrawableContainer.DrawableContainerState) state;
            for (Drawable child : containerState.getChildren()) {
                if (!shouldMutateBackground(child)) {
                    return false;
                }
            }
        }
    }
    return true;
}
 
開發者ID:iQuick,項目名稱:AndroidTint,代碼行數:26,代碼來源:EmTintManager.java

示例7: createButtonShape

import android.graphics.drawable.InsetDrawable; //導入依賴的package包/類
private static Drawable createButtonShape(Context context, int color) {
    // Translation of Lollipop's xml button-bg definition to Java
    int paddingH = context.getResources()
            .getDimensionPixelSize(R.dimen.button_padding_horizontal_material);
    int paddingV = context.getResources()
            .getDimensionPixelSize(R.dimen.button_padding_vertical_material);
    int insetH = context.getResources()
            .getDimensionPixelSize(R.dimen.button_inset_horizontal_material);
    int insetV = context.getResources()
            .getDimensionPixelSize(R.dimen.button_inset_vertical_material);

    float[] outerRadii = new float[8];
    Arrays.fill(outerRadii, CORNER_RADIUS);

    RoundRectShape r = new RoundRectShape(outerRadii, null, null);

    ShapeDrawable shapeDrawable = new ShapeDrawable(r);
    shapeDrawable.getPaint().setColor(color);
    shapeDrawable.setPadding(paddingH, paddingV, paddingH, paddingV);

    return new InsetDrawable(shapeDrawable,
            insetH, insetV, insetH, insetV);
}
 
開發者ID:andela-kogunde,項目名稱:CheckSmarter,代碼行數:24,代碼來源:SUtils.java

示例8: onCreate

import android.graphics.drawable.InsetDrawable; //導入依賴的package包/類
@Override
protected void onCreate(Bundle savedInstanceState) {
	super.onCreate(savedInstanceState);
	setContentView(R.layout.activity_d__inset_drawable);
	
	InsetDrawable insetDrawable=new InsetDrawable(getResources().getDrawable(R.drawable.animate_shower), 20, 30, 30, 20); 

	/*
	 * xml:
	 * 
	 * <inset xmlns:android="http://schemas.android.com/apk/res/android"   
		    android:drawable="@drawable/image4"  
		    android:insetLeft="50dp"  
		    android:insetRight="50dp"  
		    android:insetTop="20dp"  
		    android:insetBottom="20dp">  
		</inset>
	 */
	findViewById(R.id.tv).setBackground(insetDrawable);
}
 
開發者ID:cowthan,項目名稱:AyoSunny,代碼行數:21,代碼來源:D_InsetDrawable.java

示例9: setSettingBackground

import android.graphics.drawable.InsetDrawable; //導入依賴的package包/類
@SuppressWarnings("deprecation")
private void setSettingBackground(int resid) {
    int[] rect = new int[4];
    rect[0] = getPaddingLeft();
    rect[1] = getPaddingTop();
    rect[2] = getPaddingRight();
    rect[3] = getPaddingBottom();
    if (isInsetDrawable()) {
        setBackgroundDrawable(new InsetDrawable(getContext().getResources()
                .getDrawable(resid), mInsetDrawableRect[0],
                mInsetDrawableRect[1], mInsetDrawableRect[2],
                mInsetDrawableRect[3]));
    } else {
        setBackgroundResource(resid);
    }
    setPadding(rect[0], rect[1], rect[2], rect[3]);
}
 
開發者ID:zhangjingpu,項目名稱:youkes_vr,代碼行數:18,代碼來源:SettingItem.java

示例10: getRectWithCustomSize

import android.graphics.drawable.InsetDrawable; //導入依賴的package包/類
public Drawable getRectWithCustomSize() {
	String leftText = "I";
	String rightText = "J";

	TextDrawable.IBuilder builder = TextDrawable.builder().beginConfig()
			.width(toPx(29)).withBorder(toPx(2)).endConfig().rect();

	TextDrawable left = builder.build(leftText,
			mGenerator.getColor(leftText));

	TextDrawable right = builder.build(rightText,
			mGenerator.getColor(rightText));

	Drawable[] layerList = { new InsetDrawable(left, 0, 0, toPx(31), 0),
			new InsetDrawable(right, toPx(31), 0, 0, 0) };
	return new LayerDrawable(layerList);
}
 
開發者ID:himanshuagarwal77225,項目名稱:BookMySkills,代碼行數:18,代碼來源:DrawableProvider.java

示例11: getRectWithCustomSize

import android.graphics.drawable.InsetDrawable; //導入依賴的package包/類
public Drawable getRectWithCustomSize() {
    String leftText = "I";
    String rightText = "J";

    TextDrawable.IBuilder builder = TextDrawable.builder()
            .beginConfig()
                .width(toPx(29))
                .withBorder(toPx(2))
            .endConfig()
            .rect();

    TextDrawable left = builder
            .build(leftText, mGenerator.getColor(leftText));

    TextDrawable right = builder
            .build(rightText, mGenerator.getColor(rightText));

    Drawable[] layerList = {
            new InsetDrawable(left, 0, 0, toPx(31), 0),
            new InsetDrawable(right, toPx(31), 0, 0, 0)
    };
    return new LayerDrawable(layerList);
}
 
開發者ID:apache,項目名稱:incubator-wave-android,代碼行數:24,代碼來源:DrawableProvider.java

示例12: onUpdateBackgroundAndPaddings

import android.graphics.drawable.InsetDrawable; //導入依賴的package包/類
private void onUpdateBackgroundAndPaddings(Rect padding) {
    // Apply the top-bottom padding to itself so that the launcher transition is
    // clipped correctly
    setPadding(0, padding.top, 0, padding.bottom);

    InsetDrawable background = new InsetDrawable(mRevealDrawable,
            padding.left, 0, padding.right, 0);
    mRevealView.setBackground(background.getConstantState().newDrawable());
    mContent.setBackground(background);

    // We let the content have a intent background, but still have full width.
    // This allows the scroll bar to be used responsive outside the background bounds as well.
    mContent.setPadding(0, 0, 0, 0);

    Rect bgPadding = new Rect();
    background.getPadding(bgPadding);
    onUpdateBgPadding(padding, bgPadding);
}
 
開發者ID:RunasSudo,項目名稱:FLauncher,代碼行數:19,代碼來源:BaseContainerView.java

示例13: init

import android.graphics.drawable.InsetDrawable; //導入依賴的package包/類
private void init(Context context) {
  setBackground(new InsetDrawable(new Triangle(context.getResources()
      .getColor(R.color.vote_state_empty)),
      (int) Views.convertDpToPixel(12, context),
      (int) Views.convertDpToPixel(4, context),
      (int) Views.convertDpToPixel(12, context),
      (int) Views.convertDpToPixel(4, context)));
  voteState = Vote.VoteState.EMPTY;
  setOnClickListener(v -> {
    if (onVoteClickListener != null) {
      Vote.VoteState from = this.voteState;
      Vote.VoteState to = (this.voteState == Vote.VoteState.EMPTY
                           ? Vote.VoteState.UP
                           : Vote.VoteState.EMPTY);
      onVoteClickListener.onVoteClicked(from, to);
    }
  });
}
 
開發者ID:kaif-open,項目名稱:kaif-android,代碼行數:19,代碼來源:VoteArticleButton.java

示例14: assertEquals

import android.graphics.drawable.InsetDrawable; //導入依賴的package包/類
public static void assertEquals(InsetDrawable a,InsetDrawable b)
{
    assertEqualsDrawableWrapper(a, b);

    assertEquals(a.isStateful(), b.isStateful());
    // android:visible
    assertEquals(a.isVisible(), b.isVisible());

    Drawable.ConstantState a_state = a.getConstantState();
    Drawable.ConstantState b_state = b.getConstantState();

    Class classInsetState = TestUtil.resolveClass(InsetDrawable.class.getName() + "$InsetState");
    assertEquals((Integer) TestUtil.getField(a_state, classInsetState, "mInsetLeft"), (Integer) TestUtil.getField(b_state, classInsetState, "mInsetLeft"));
    assertEquals((Integer) TestUtil.getField(a_state, classInsetState, "mInsetTop"), (Integer) TestUtil.getField(b_state, classInsetState, "mInsetTop"));
    assertEquals((Integer) TestUtil.getField(a_state, classInsetState, "mInsetRight"), (Integer) TestUtil.getField(b_state, classInsetState, "mInsetRight"));
    assertEquals((Integer) TestUtil.getField(a_state, classInsetState, "mInsetBottom"), (Integer) TestUtil.getField(b_state, classInsetState, "mInsetBottom"));

    // android:drawable
    if (Build.VERSION.SDK_INT < TestUtil.MARSHMALLOW) // < 23 (en level 23 mDrawable está en la clase base)
    {
        assertEquals((Drawable) TestUtil.getField(a_state, classInsetState, "mDrawable"), (Drawable) TestUtil.getField(b_state, classInsetState, "mDrawable"));
    }
}
 
開發者ID:jmarranz,項目名稱:itsnat_droid,代碼行數:24,代碼來源:Assert.java

示例15: getRectWithCustomSize

import android.graphics.drawable.InsetDrawable; //導入依賴的package包/類
public Drawable getRectWithCustomSize(Context context, String leftText, String rightText, boolean selected) {

        TextDrawable.IBuilder builder = TextDrawable.builder()
                .beginConfig()
                .width(toPx(context, 29))
                .withBorder(toPx(context, 2))
                .textColor(selected ? getTextColorSelected() : getTextColorUnselected())
                .endConfig()
                .rect();


        TextDrawable left = builder
                .build(leftText, mGenerator.getColor(leftText));


        TextDrawable right = builder
                .build(rightText, mGenerator.getColor(rightText));


        Drawable[] layerList = {
                new InsetDrawable(left, 0, 0, toPx(context, 31), 0),
                new InsetDrawable(right, toPx(context, 31), 0, 0, 0)
        };
        return new LayerDrawable(layerList);
    }
 
開發者ID:TouchBoarder,項目名稱:weekdays-buttons-bar,代碼行數:26,代碼來源:WeekdaysDrawableProvider.java


注:本文中的android.graphics.drawable.InsetDrawable類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。