Java Code Examples for android.widget.LinearLayout#getBackground()

The following examples show how to use android.widget.LinearLayout#getBackground() . 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: AppLauncher.java    From DistroHopper with GNU General Public License v3.0 6 votes vote down vote up
protected void iconChanged ()
{
	if (! this.isInEditMode () && (this.icon != null))
	{
		ImageView imgIcon = (ImageView) this.findViewById (R.id.imgIcon);
		imgIcon.setImageDrawable (this.icon.getDrawable ());

		LinearLayout llBackground = (LinearLayout) this.findViewById (R.id.llBackground);
		if (llBackground != null && (! this.special) && this.getResources ().getBoolean (HomeActivity.theme.launcher_applauncher_backgroundcolour_dynamic))
		{
			final SharedPreferences prefs = Preferences.getSharedPreferences(this.context, Preferences.PREFERENCES);

			final int avgColour = this.icon.getAverageColour(prefs.getInt (Preference.LAUNCHERICON_OPACITY.getName(), 204));

			final GradientDrawable gd = (GradientDrawable) llBackground.getBackground ();
			gd.setColor (avgColour);
		}
	}
}
 
Example 2
Source File: FollowUserInputActivity.java    From Android-3D-Layout with MIT License 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_follow_user_input);

    LinearLayout container = (LinearLayout) findViewById(R.id.container);
    anim = (AnimationDrawable) container.getBackground();
    anim.setEnterFadeDuration(6000);
    anim.setExitFadeDuration(2000);
}
 
Example 3
Source File: ViewMaker.java    From iGap-Android with GNU Affero General Public License v3.0 5 votes vote down vote up
private static View getForwardButton() {
    LinearLayout lyt_vote_forward = new LinearLayout(context);
    lyt_vote_forward.setGravity(CENTER);
    lyt_vote_forward.setOrientation(VERTICAL);


    lyt_vote_forward.setBackgroundDrawable(G.context.getResources().getDrawable(R.drawable.circle_white));

    GradientDrawable circleDarkColor = (GradientDrawable) lyt_vote_forward.getBackground();
    circleDarkColor.setColor(Color.parseColor(G.appBarColor));

    LinearLayout.LayoutParams layout_799_f = new LinearLayout.LayoutParams(i_Dp(R.dimen.dp32), i_Dp(R.dimen.dp32));
    layout_799_f.topMargin = i_Dp(R.dimen.dp8);
    layout_799_f.bottomMargin = i_Dp(R.dimen.dp16);
    layout_799_f.leftMargin = i_Dp(R.dimen.dp2);
    lyt_vote_forward.setLayoutParams(layout_799_f);

    MaterialDesignTextView img_vote_forward = new MaterialDesignTextView(context);
    img_vote_forward.setId(R.id.img_vote_forward);
    img_vote_forward.setPadding(i_Dp(R.dimen.dp2), i_Dp(R.dimen.dp4), 0, 0);
    img_vote_forward.setGravity(CENTER);
    LinearLayout.LayoutParams layout_216_f = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
    img_vote_forward.setText(context.getResources().getString(R.string.md_forward));
    img_vote_forward.setTextColor(Color.parseColor(G.voteIconTheme));
    setTextSize(img_vote_forward, R.dimen.dp20);
    img_vote_forward.setLayoutParams(layout_216_f);
    lyt_vote_forward.addView(img_vote_forward);

    return lyt_vote_forward;
}
 
Example 4
Source File: BoardFragment.java    From DragListView with Apache License 2.0 5 votes vote down vote up
@Override
public void onBindDragView(View clickedView, View dragView) {
    LinearLayout clickedLayout = (LinearLayout) clickedView;
    View clickedHeader = clickedLayout.getChildAt(0);
    RecyclerView clickedRecyclerView = (RecyclerView) clickedLayout.getChildAt(1);

    View dragHeader = dragView.findViewById(R.id.drag_header);
    ScrollView dragScrollView = dragView.findViewById(R.id.drag_scroll_view);
    LinearLayout dragLayout = dragView.findViewById(R.id.drag_list);

    Drawable clickedColumnBackground = clickedLayout.getBackground();
    if (clickedColumnBackground != null) {
        ViewCompat.setBackground(dragView, clickedColumnBackground);
    }

    Drawable clickedRecyclerBackground = clickedRecyclerView.getBackground();
    if (clickedRecyclerBackground != null) {
        ViewCompat.setBackground(dragLayout, clickedRecyclerBackground);
    }

    dragLayout.removeAllViews();

    ((TextView) dragHeader.findViewById(R.id.text)).setText(((TextView) clickedHeader.findViewById(R.id.text)).getText());
    ((TextView) dragHeader.findViewById(R.id.item_count)).setText(((TextView) clickedHeader.findViewById(R.id.item_count)).getText());
    for (int i = 0; i < clickedRecyclerView.getChildCount(); i++) {
        View view = View.inflate(dragView.getContext(), R.layout.column_item, null);
        ((TextView) view.findViewById(R.id.text)).setText(((TextView) clickedRecyclerView.getChildAt(i).findViewById(R.id.text)).getText());
        dragLayout.addView(view);

        if (i == 0) {
            dragScrollView.setScrollY(-clickedRecyclerView.getChildAt(i).getTop());
        }
    }

    dragView.setPivotY(0);
    dragView.setPivotX(clickedView.getMeasuredWidth() / 2);
}
 
Example 5
Source File: CommentActivity.java    From NoiseCapture with GNU General Public License v3.0 5 votes vote down vote up
private void addTag(String tagName, int id, ViewGroup column, int color) {
    ToggleButton tagButton = new ToggleButton(this);
    if(color != -1) {
        LinearLayout colorBox = new LinearLayout(this);
        // Convert the dps to pixels, based on density scale
        final int tagPaddingPx = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP,
                1, getResources().getDisplayMetrics());
        final int tagPaddingPxBottom = (int) TypedValue.applyDimension(TypedValue
                .COMPLEX_UNIT_DIP,
                3, getResources().getDisplayMetrics());
        //use a GradientDrawable with only one color set, to make it a solid color
        colorBox.setBackgroundResource(R.drawable.tag_round_corner);
        GradientDrawable gradientDrawable = (GradientDrawable) colorBox.getBackground();
        gradientDrawable.setColor(color);
        LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(ViewGroup.LayoutParams
                .MATCH_PARENT,
                ViewGroup.LayoutParams.WRAP_CONTENT);
        params.setMargins(tagPaddingPx,tagPaddingPx,tagPaddingPx,tagPaddingPxBottom);
        colorBox.setLayoutParams(params);
        colorBox.addView(tagButton);
        column.addView(colorBox);
    } else {
        column.addView(tagButton);
    }
    tagButton.setTextOff(tagName);
    tagButton.setTextOn(tagName);
    boolean isChecked = checkedTags.contains(id);
    tagButton.setChecked(isChecked);
    if(isChecked) {
        tagButton.setTextColor(selectedColor);
    }
    tagButton.setOnCheckedChangeListener(new TagStateListener(id, checkedTags));
    tagButton.setMinHeight(0);
    tagButton.setMinimumHeight(0);
    tagButton.setTextSize(Dimension.SP, 12);
    tagButton.setEnabled(record == null || record.getUploadId().isEmpty());
    tagButton.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.WRAP_CONTENT));
    tagButton.invalidate();
}
 
Example 6
Source File: RunningAppLauncher.java    From DistroHopper with GNU General Public License v3.0 5 votes vote down vote up
@Override
protected void colourChanged ()
{
	LinearLayout llBackground = (LinearLayout) this.findViewById (R.id.llBackground);
	GradientDrawable gd = (GradientDrawable) llBackground.getBackground ();
	gd.setColor (this.getColour ());
}
 
Example 7
Source File: ViewMaker.java    From iGap-Android with GNU Affero General Public License v3.0 4 votes vote down vote up
static View getViewVote() {

        LinearLayout lyt_vote = new LinearLayout(context);
        lyt_vote.setId(R.id.lyt_vote);
        lyt_vote.setGravity(BOTTOM);
        setLayoutDirection(lyt_vote, View.LAYOUT_DIRECTION_LTR);
        lyt_vote.setOrientation(VERTICAL);
        LinearLayout.LayoutParams layout_356 = new LinearLayout.LayoutParams(i_Dp(R.dimen.dp48), ViewGroup.LayoutParams.MATCH_PARENT);
        layout_356.gravity = BOTTOM;
        lyt_vote.setLayoutParams(layout_356);

        LinearLayout lyt_vote_sub = new LinearLayout(context);
        lyt_vote_sub.setOrientation(VERTICAL);
        lyt_vote_sub.setId(R.id.lyt_vote_sub);

        lyt_vote_sub.setBackgroundDrawable(G.context.getResources().getDrawable(R.drawable.rectangel_white_round));


        GradientDrawable circleDarkColor = (GradientDrawable) lyt_vote_sub.getBackground();
        circleDarkColor.setColor(Color.parseColor(G.appBarColor));

        LinearLayout.LayoutParams layout_35644 = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
        layout_35644.leftMargin = i_Dp(R.dimen.dp2);
        lyt_vote_sub.setLayoutParams(layout_35644);

        LinearLayout lyt_vote_up = new LinearLayout(context);
        lyt_vote_up.setId(R.id.lyt_vote_up);
        lyt_vote_up.setGravity(CENTER);
        lyt_vote_up.setOrientation(VERTICAL);
        LinearLayout.LayoutParams layout_799 = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
        lyt_vote_up.setPadding(0, 0, 0, i_Dp(R.dimen.dp6));
        layout_799.bottomMargin = i_Dp(dp4);
        lyt_vote_up.setLayoutParams(layout_799);

        TextView txt_vote_up = new TextView(context);
        txt_vote_up.setId(R.id.txt_vote_up);
        txt_vote_up.setText("0");
        txt_vote_up.setTextAppearance(context, R.style.ChatMessages_Time);
        txt_vote_up.setSingleLine(true);
        setTypeFace(txt_vote_up);

        txt_vote_up.setTextColor(Color.parseColor(G.voteIconTheme));
        LinearLayout.LayoutParams layout_713 = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, dpToPixel(16));
        txt_vote_up.setLayoutParams(layout_713);
        lyt_vote_up.addView(txt_vote_up);

        MaterialDesignTextView img_vote_up = new MaterialDesignTextView(context);
        img_vote_up.setId(R.id.img_vote_up);
        img_vote_up.setText(context.getResources().getString(R.string.md_thumb_up));
        img_vote_up.setTextColor(Color.parseColor(G.voteIconTheme));
        setTextSize(img_vote_up, R.dimen.dp16);
        LinearLayout.LayoutParams layout_216 = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
        img_vote_up.setLayoutParams(layout_216);
        lyt_vote_up.addView(img_vote_up);
        lyt_vote_sub.addView(lyt_vote_up);

        LinearLayout lyt_vote_down = new LinearLayout(context);

        lyt_vote_down.setBackgroundDrawable(G.context.getResources().getDrawable(R.drawable.rectangel_white_round));

        GradientDrawable circleDarkColor_2 = (GradientDrawable) lyt_vote_down.getBackground();
        circleDarkColor_2.setColor(Color.parseColor(G.appBarColor));

        lyt_vote_down.setId(R.id.lyt_vote_down);
        lyt_vote_down.setPadding(0, i_Dp(R.dimen.dp6), 0, 0);
        lyt_vote_down.setGravity(CENTER);
        lyt_vote_down.setOrientation(VERTICAL);
        LinearLayout.LayoutParams layout_221 = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
        lyt_vote_down.setLayoutParams(layout_221);

        MaterialDesignTextView img_vote_down = new MaterialDesignTextView(context);
        img_vote_down.setId(R.id.img_vote_down);
        img_vote_down.setText(context.getResources().getString(R.string.md_thumb_down));
        img_vote_down.setTextColor(Color.parseColor(G.voteIconTheme));
        setTextSize(img_vote_down, R.dimen.dp16);
        LinearLayout.LayoutParams layout_877 = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
        img_vote_down.setLayoutParams(layout_877);
        lyt_vote_down.addView(img_vote_down);

        TextView txt_vote_down = new TextView(context);
        txt_vote_down.setId(R.id.txt_vote_down);
        txt_vote_down.setText("0");
        txt_vote_down.setTextAppearance(context, R.style.ChatMessages_Time);
        setTypeFace(txt_vote_down);
        txt_vote_down.setSingleLine(true);
        txt_vote_down.setTextColor(Color.parseColor(G.voteIconTheme));
        LinearLayout.LayoutParams layout_856 = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, dpToPixel(16));
        txt_vote_down.setLayoutParams(layout_856);

        lyt_vote_down.addView(txt_vote_down);
        lyt_vote_sub.addView(lyt_vote_down);
        lyt_vote.addView(lyt_vote_sub);
        lyt_vote.addView(getForwardButton());

        return lyt_vote;
    }
 
Example 8
Source File: AppLauncher.java    From DistroHopper with GNU General Public License v3.0 4 votes vote down vote up
protected void colourChanged ()
{
	LinearLayout llBackground = (LinearLayout) this.findViewById (R.id.llBackground);
	GradientDrawable gd = (GradientDrawable) llBackground.getBackground ();
	gd.setColor (this.colour);
}