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

The following examples show how to use android.widget.LinearLayout#setBackgroundDrawable() . 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: ThemeUtil.java    From YiBo with Apache License 2.0 6 votes vote down vote up
public static void setSecondaryImageHeader(View headerView) {
	if (headerView == null) {
		return;
	}
	Theme theme = ThemeUtil.createTheme(headerView.getContext());
	LinearLayout llHeaderBase = (LinearLayout)headerView.findViewById(R.id.llHeaderBase);
	Button btnBack = (Button)headerView.findViewById(R.id.btnBack);
	Button btnOperate = (Button) headerView.findViewById(R.id.btnOperate);
	TextView tvTitle = (TextView) headerView.findViewById(R.id.tvTitle);
	
	llHeaderBase.setBackgroundDrawable(theme.getDrawable("bg_header_image"));
	llHeaderBase.setGravity(Gravity.CENTER);
	int padding8 = theme.dip2px(8);
	llHeaderBase.setPadding(padding8, 0, padding8, 0);
	btnBack.setBackgroundDrawable(theme.getDrawable("selector_btn_action_back"));
	btnBack.setTextColor(theme.getColorStateList("selector_btn_header_action"));
	tvTitle.setTextColor(theme.getColorStateList("selector_header_title"));
	btnOperate.setBackgroundDrawable(theme.getDrawable("selector_btn_action_additional"));
	int padding12 = theme.dip2px(12); 
	btnOperate.setPadding(padding12, 0, padding12, 0);
	btnOperate.setTextColor(theme.getColor("selector_btn_header_action"));
}
 
Example 2
Source File: EmptyLoadingView.java    From android_tv_metro with Apache License 2.0 6 votes vote down vote up
@SuppressWarnings("deprecation")
private void init(Context context) {
	LayoutInflater.from(context).inflate(R.layout.empty_loading_layout, this);
	mProgressLayout = (LinearLayout) this.findViewById(R.id.progress_layout);
	mProgressView = (ImageView) this.findViewById(R.id.empty_progress_view);

	mEmptyView = (LinearLayout) this.findViewById(R.id.empty_layout);
       if(Build.VERSION.SDK_INT >= 16){
           mEmptyView.setBackground(null);
       }else {
           mEmptyView.setBackgroundDrawable(null);
       }
	mTextView = (TextView) this.findViewById(R.id.empty_textview);
	mTextView.getPaint().setFakeBoldText(true);

}
 
Example 3
Source File: WaitPDPActivity.java    From DroidForce with GNU Lesser General Public License v2.1 6 votes vote down vote up
/**
 * Setup the layout for the activity
 */
private void setLayout() {		
	Log.i("DroidForce", "Setting up layout...");
	LinearLayout llayout = new LinearLayout(this);

	LinearLayout.LayoutParams llp = new LinearLayout.LayoutParams( 
			LinearLayout.LayoutParams.FILL_PARENT,
			LinearLayout.LayoutParams.FILL_PARENT);

	llayout.setBackgroundDrawable(loadBackground());
	llayout.setGravity(Gravity.BOTTOM | Gravity.CENTER_HORIZONTAL);
	
       TextView tv = new TextView(this);
       LayoutParams lpView = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
       tv.setText("Powered by DroidForce.");
       tv.setLayoutParams(lpView);  
       
       llayout.addView(tv);
	
	setContentView(llayout);
	

}
 
Example 4
Source File: ThemeUtil.java    From YiBo with Apache License 2.0 6 votes vote down vote up
public static void setSecondaryHeader(View headerView) {
	if (headerView == null) {
		return;
	}
	Theme theme = ThemeUtil.createTheme(headerView.getContext());
	LinearLayout llHeaderBase = (LinearLayout)headerView.findViewById(R.id.llHeaderBase);
	Button btnBack = (Button)headerView.findViewById(R.id.btnBack);
	Button btnOperate = (Button) headerView.findViewById(R.id.btnOperate);
	TextView tvTitle = (TextView) headerView.findViewById(R.id.tvTitle);
	
	llHeaderBase.setBackgroundDrawable(theme.getDrawable("bg_header"));
	llHeaderBase.setGravity(Gravity.CENTER);
	int padding8 = theme.dip2px(8);
	llHeaderBase.setPadding(padding8, 0, padding8, 0);
	btnBack.setBackgroundDrawable(theme.getDrawable("selector_btn_action_back"));
	btnBack.setTextColor(theme.getColorStateList("selector_btn_header_action"));
	tvTitle.setTextColor(theme.getColorStateList("selector_header_title"));
	btnOperate.setBackgroundDrawable(theme.getDrawable("selector_btn_action_additional"));
	int padding12 = theme.dip2px(12);
	btnOperate.setPadding(padding12, 0, padding12, 0);
	btnOperate.setTextColor(theme.getColor("selector_btn_header_action"));
}
 
Example 5
Source File: SwipeMenuView.java    From SwipeMenuAndRefresh with Apache License 2.0 6 votes vote down vote up
private void addItem(SwipeMenuItem item, int id) {
	LayoutParams params = new LayoutParams(item.getWidth(),
			LayoutParams.MATCH_PARENT);
	LinearLayout parent = new LinearLayout(getContext());
	parent.setId(id);
	parent.setGravity(Gravity.CENTER);
	parent.setOrientation(LinearLayout.VERTICAL);
	parent.setLayoutParams(params);
	parent.setBackgroundDrawable(item.getBackground());
	parent.setOnClickListener(this);
	addView(parent);

	if (item.getIcon() != null) {
		parent.addView(createIcon(item));
	}
	if (!TextUtils.isEmpty(item.getTitle())) {
		parent.addView(createTitle(item));
	}

}
 
Example 6
Source File: SwipeMenuView.java    From HPlayer with Apache License 2.0 6 votes vote down vote up
private void addItem(SwipeMenuItem item, int id) {
	LayoutParams params = new LayoutParams(item.getWidth(),
			LayoutParams.MATCH_PARENT);
	LinearLayout parent = new LinearLayout(getContext());
	parent.setId(id);
	parent.setGravity(Gravity.CENTER);
	parent.setOrientation(LinearLayout.VERTICAL);
	parent.setLayoutParams(params);
	parent.setBackgroundDrawable(item.getBackground());
	parent.setOnClickListener(this);
	addView(parent);

	if (item.getIcon() != null) {
		parent.addView(createIcon(item));
	}
	if (!TextUtils.isEmpty(item.getTitle())) {
		parent.addView(createTitle(item));
	}

}
 
Example 7
Source File: RxRoundProgressBar.java    From RxTools-master with Apache License 2.0 6 votes vote down vote up
@SuppressWarnings("deprecation")
@Override
protected void drawProgress(LinearLayout layoutProgress, float max, float progress, float totalWidth,
                            int radius, int padding, int colorProgress, boolean isReverse) {
    GradientDrawable backgroundDrawable = createGradientDrawable(colorProgress);
    int newRadius = radius - (padding / 2);
    backgroundDrawable.setCornerRadii(new float[]{newRadius, newRadius, newRadius, newRadius, newRadius, newRadius, newRadius, newRadius});
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
        layoutProgress.setBackground(backgroundDrawable);
    } else {
        layoutProgress.setBackgroundDrawable(backgroundDrawable);
    }

    float ratio = max / progress;
    int progressWidth = (int) ((totalWidth - (padding * 2)) / ratio);
    ViewGroup.LayoutParams progressParams = layoutProgress.getLayoutParams();
    progressParams.width = progressWidth;
    layoutProgress.setLayoutParams(progressParams);
}
 
Example 8
Source File: SwipeMenuView.java    From android2048 with Apache License 2.0 6 votes vote down vote up
private void addItem(SwipeMenuItem item, int id) {
	LayoutParams params = new LayoutParams(item.getWidth(),
			LayoutParams.MATCH_PARENT);
	LinearLayout parent = new LinearLayout(getContext());
	parent.setId(id);
	parent.setGravity(Gravity.CENTER);
	parent.setOrientation(LinearLayout.VERTICAL);
	parent.setLayoutParams(params);
	parent.setBackgroundDrawable(item.getBackground());
	parent.setOnClickListener(this);
	addView(parent);

	if (item.getIcon() != null) {
		parent.addView(createIcon(item));
	}
	if (!TextUtils.isEmpty(item.getTitle())) {
		parent.addView(createTitle(item));
	}

}
 
Example 9
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 10
Source File: PhotoPaintView.java    From Telegram-FOSS with GNU General Public License v2.0 5 votes vote down vote up
private LinearLayout buttonForText(int type, String text, int icon, boolean selected) {
    LinearLayout button = new LinearLayout(getContext()) {
        @Override
        public boolean onInterceptTouchEvent(MotionEvent ev) {
            return true;
        }
    };
    button.setOrientation(LinearLayout.HORIZONTAL);
    button.setBackgroundDrawable(Theme.getSelectorDrawable(false));
    button.setOnClickListener(v -> {
        setType(type);

        if (popupWindow != null && popupWindow.isShowing()) {
            popupWindow.dismiss(true);
        }
    });

    ImageView imageView = new ImageView(getContext());
    imageView.setScaleType(ImageView.ScaleType.CENTER);
    imageView.setImageResource(icon);
    imageView.setColorFilter(Theme.getColor(Theme.key_actionBarDefaultSubmenuItem));
    button.addView(imageView, LayoutHelper.createLinear(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, Gravity.LEFT | Gravity.CENTER_VERTICAL, 16, 0, 16, 0));

    TextView textView = new TextView(getContext());
    textView.setTextColor(Theme.getColor(Theme.key_actionBarDefaultSubmenuItem));
    textView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 16);
    textView.setText(text);
    button.addView(textView, LayoutHelper.createLinear(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, Gravity.LEFT | Gravity.CENTER_VERTICAL, 0, 0, 16, 0));

    if (selected) {
        ImageView check = new ImageView(getContext());
        check.setImageResource(R.drawable.msg_text_check);
        check.setScaleType(ImageView.ScaleType.CENTER);
        check.setColorFilter(new PorterDuffColorFilter(Theme.getColor(Theme.key_radioBackgroundChecked), PorterDuff.Mode.MULTIPLY));
        button.addView(check, LayoutHelper.createFrame(50, LayoutHelper.MATCH_PARENT));
    }

    return button;
}
 
Example 11
Source File: ActionSheetDialog.java    From RecordVideo with Apache License 2.0 5 votes vote down vote up
@SuppressWarnings("deprecation")
@Override
public View getView(int position, View convertView, ViewGroup parent) {
    final DialogMenuItem item = mContents.get(position);

    LinearLayout llItem = new LinearLayout(mContext);
    llItem.setOrientation(LinearLayout.HORIZONTAL);
    llItem.setGravity(Gravity.CENTER_VERTICAL);

    ImageView ivItem = new ImageView(mContext);
    ivItem.setPadding(0, 0, dp2px(15), 0);
    llItem.addView(ivItem);

    TextView tvItem = new TextView(mContext);
    tvItem.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT));
    tvItem.setSingleLine(true);
    tvItem.setGravity(Gravity.CENTER);
    tvItem.setTextColor(mItemTextColor);
    tvItem.setTextSize(TypedValue.COMPLEX_UNIT_SP, mItemTextSize);
    tvItem.setHeight(dp2px(mItemHeight));

    llItem.addView(tvItem);
    float radius = dp2px(mCornerRadius);
    if (mIsTitleShow) {
        llItem.setBackgroundDrawable((CornerUtils.listItemSelector(radius, Color.TRANSPARENT, mItemPressColor,
                position == mContents.size() - 1)));
    } else {
        llItem.setBackgroundDrawable(CornerUtils.listItemSelector(radius, Color.TRANSPARENT, mItemPressColor,
                mContents.size(), position));
    }

    ivItem.setImageResource(item.mResId);
    tvItem.setText(item.mOperName);
    ivItem.setVisibility(item.mResId == 0 ? View.GONE : View.VISIBLE);

    return llItem;
}
 
Example 12
Source File: AbstractTreeViewAdapter.java    From satstat with GNU General Public License v3.0 5 votes vote down vote up
public final LinearLayout populateTreeItem(final LinearLayout layout,
        final View childView, final TreeNodeInfo<T> nodeInfo,
        final boolean newChildView) {
    final Drawable individualRowDrawable = getBackgroundDrawable(nodeInfo);
    layout.setBackgroundDrawable(individualRowDrawable == null ? getDrawableOrDefaultBackground(rowBackgroundDrawable)
            : individualRowDrawable);
    final LinearLayout.LayoutParams indicatorLayoutParams = new LinearLayout.LayoutParams(
            calculateIndentation(nodeInfo), LayoutParams.FILL_PARENT);
    final LinearLayout indicatorLayout = (LinearLayout) layout
            .findViewById(R.id.treeview_list_item_image_layout);
    indicatorLayout.setGravity(indicatorGravity);
    indicatorLayout.setLayoutParams(indicatorLayoutParams);
    final ImageView image = (ImageView) layout
            .findViewById(R.id.treeview_list_item_image);
    image.setImageDrawable(getDrawable(nodeInfo));
    image.setScaleType(ScaleType.CENTER);
    image.setTag(nodeInfo.getId());
    image.setOnClickListener(null);
    image.setClickable(false);
    layout.setTag(nodeInfo.getId());
    final FrameLayout frameLayout = (FrameLayout) layout
            .findViewById(R.id.treeview_list_item_frame);
    final FrameLayout.LayoutParams childParams = new FrameLayout.LayoutParams(
            LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT);
    if (newChildView) {
        frameLayout.addView(childView, childParams);
    }
    frameLayout.setTag(nodeInfo.getId());
    return layout;
}
 
Example 13
Source File: AProgressBar.java    From Stylish-Widget-for-Android with Apache License 2.0 5 votes vote down vote up
private GradientDrawable createGradientDrawableWithCorner(LinearLayout layout, int color) {
        GradientDrawable backgroundDrawable = createGradientDrawable(color);
        int newRadius = radius;
        backgroundDrawable.setCornerRadii(new float[]{newRadius, newRadius, newRadius, newRadius, newRadius, newRadius, newRadius, newRadius});

//        backgroundDrawable.setCornerRadii(new float[]{0, 0, newRadius, newRadius, newRadius, newRadius, 0, 0});

        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
            layout.setBackground(backgroundDrawable);
        } else {
            layout.setBackgroundDrawable(backgroundDrawable);
        }
        return backgroundDrawable;
    }
 
Example 14
Source File: EditDirectMessageActivity.java    From YiBo with Apache License 2.0 4 votes vote down vote up
private void initComponents() {
	LinearLayout llHeaderBase = (LinearLayout)findViewById(R.id.llHeaderBase);
	LinearLayout llContentPanel = (LinearLayout)findViewById(R.id.llContentPanel);
	AutoCompleteTextView etDisplayName = (AutoCompleteTextView)this.findViewById(R.id.etDisplayName);
	Button btnUserSelector = (Button)this.findViewById(R.id.btnUserSelector);
	LinearLayout llEditText = (LinearLayout)findViewById(R.id.llEditText);
	MultiAutoCompleteTextView etText  = (MultiAutoCompleteTextView)findViewById(R.id.etText);
	Button btnEmotion = (Button)this.findViewById(R.id.btnEmotion);
	Button btnMention = (Button)this.findViewById(R.id.btnMention);
	Button btnTopic = (Button)this.findViewById(R.id.btnTopic);
	Button btnTextCount = (Button)this.findViewById(R.id.btnTextCount);
	
	ThemeUtil.setSecondaryHeader(llHeaderBase);
	ThemeUtil.setContentBackground(llContentPanel);
	int padding6 = theme.dip2px(6);
	int padding8 = theme.dip2px(8);
	llContentPanel.setPadding(padding6, padding8, padding6, 0);
	etDisplayName.setBackgroundDrawable(theme.getDrawable("bg_input_frame_left_half"));
	etDisplayName.setTextColor(theme.getColor("content"));
	btnUserSelector.setBackgroundDrawable(theme.getDrawable("selector_btn_message_user"));
	llEditText.setBackgroundDrawable(theme.getDrawable("bg_input_frame_normal"));
	etText.setTextColor(theme.getColor("content"));
	btnEmotion.setBackgroundDrawable(theme.getDrawable("selector_btn_emotion"));
	btnMention.setBackgroundDrawable(theme.getDrawable("selector_btn_mention"));
	btnTopic.setBackgroundDrawable(theme.getDrawable("selector_btn_topic"));
	btnTextCount.setBackgroundDrawable(theme.getDrawable("selector_btn_text_count"));
	btnTextCount.setPadding(padding6, 0, theme.dip2px(20), 0);
	btnTextCount.setTextColor(theme.getColor("status_capability"));
	
	
	TextView tvTitle = (TextView) this.findViewById(R.id.tvTitle);
	tvTitle.setText(R.string.title_edit_direct_message);
	if (StringUtil.isNotEmpty(displayName)) {
		etDisplayName.setText(displayName);
		etText.requestFocus();
	}
	etDisplayName.setAdapter(new UserSuggestAdapter(this));
	etDisplayName.setOnTouchListener(hideEmotionGridListener);

	int length = StringUtil.getLengthByByte(etText.getText().toString());
       int leavings = (int)Math.floor((double)(Constants.STATUS_TEXT_MAX_LENGTH * 2 - length) / 2);
       btnTextCount.setText((leavings < 0 ? "-" : "") + Math.abs(leavings));
       
       emotionViewController = new EmotionViewController(this);
}
 
Example 15
Source File: MicroBlogActivity.java    From YiBo with Apache License 2.0 4 votes vote down vote up
public void initComponent() {
	LinearLayout llRoot = (LinearLayout)findViewById(R.id.llRoot);
	LinearLayout llHeaderBase = (LinearLayout)findViewById(R.id.llHeaderBase);
	ThemeUtil.setRootBackground(llRoot);
	ThemeUtil.setSecondaryMicroBlogHeader(llHeaderBase);
	
	//资料头部
	LayoutInflater inflater = LayoutInflater.from(this);
	View headerView = inflater.inflate(R.layout.include_micro_blog_list_header, null);
	LinearLayout llProfileHeader = (LinearLayout)headerView.findViewById(R.id.llProfileHeader);
	TextView tvScreenName = (TextView)headerView.findViewById(R.id.tvScreenName);
	ImageView ivVerify = (ImageView)headerView.findViewById(R.id.ivVerify);
	TextView tvImpress = (TextView)headerView.findViewById(R.id.tvImpress);
	ImageView ivMoreDetail = (ImageView)headerView.findViewById(R.id.ivMoreDetail);
	ThemeUtil.setHeaderProfile(llProfileHeader);
	int highlight = theme.getColor("highlight");
	tvScreenName.setTextColor(highlight);
	ivVerify.setImageDrawable(theme.getDrawable("icon_verification"));
	tvImpress.setTextColor(theme.getColor("content"));
	ivMoreDetail.setBackgroundDrawable(theme.getDrawable("icon_more_detail"));
	
	//微博内容
	TextView tvText = (TextView)headerView.findViewById(R.id.tvText);
	LinearLayout llThumbnailShape = (LinearLayout)headerView.findViewById(R.id.llThumbnailShape);
	TextView tvImageInfo = (TextView)headerView.findViewById(R.id.tvImageInfo);
	LinearLayout llRetweet = (LinearLayout)headerView.findViewById(R.id.llRetweet);
	TextView tvRetweetText = (TextView)headerView.findViewById(R.id.tvRetweetText);
	LinearLayout llRetweetThumbnailShape = (LinearLayout)headerView.findViewById(R.id.llRetweetThumbnailShape);
	TextView tvRetweetImageInfo = (TextView)headerView.findViewById(R.id.tvRetweetImageInfo);
	ImageView ivRetweetLocation = (ImageView)headerView.findViewById(R.id.ivRetweetLocation);
	TextView tvRetweetLocation = (TextView)headerView.findViewById(R.id.tvRetweetLocation);
	TextView tvRetweetCreatedAt = (TextView)headerView.findViewById(R.id.tvRetweetCreatedAt);
	TextView tvRetweetSource = (TextView)headerView.findViewById(R.id.tvRetweetSource);
	ImageView ivLocation = (ImageView)headerView.findViewById(R.id.ivLocation);
	TextView tvLocation = (TextView)headerView.findViewById(R.id.tvLocation);
	TextView tvCreatedAt = (TextView)headerView.findViewById(R.id.tvCreatedAt);
	TextView tvSource = (TextView)headerView.findViewById(R.id.tvSource);
	TextView tvRetweetCount = (TextView)headerView.findViewById(R.id.tvRetweetCount);
	TextView tvCommentCount = (TextView)headerView.findViewById(R.id.tvCommentCount);
	ImageView ivLineSeperator = (ImageView)headerView.findViewById(R.id.ivLineSeperator);
	
	tvText.setTextColor(theme.getColor("content"));
	ColorStateList selectorTextLink = theme.getColorStateList("selector_text_link");
	tvText.setLinkTextColor(selectorTextLink);
	Drawable shapeAttachment = theme.getDrawable("shape_attachment");
	llThumbnailShape.setBackgroundDrawable(shapeAttachment);
	int quote = theme.getColor("quote");
    tvImageInfo.setTextColor(quote);
    llRetweet.setBackgroundDrawable(theme.getDrawable("bg_retweet_frame"));
    int padding10 = theme.dip2px(10);
    llRetweet.setPadding(padding10, padding10, padding10, theme.dip2px(6));        
    tvRetweetText.setTextColor(quote);
    tvRetweetText.setLinkTextColor(selectorTextLink);
    llRetweetThumbnailShape.setBackgroundDrawable(shapeAttachment);
    tvRetweetImageInfo.setTextColor(quote);
    Drawable iconLocation = theme.getDrawable("icon_location");
    ivRetweetLocation.setImageDrawable(iconLocation);
    tvRetweetLocation.setTextColor(quote);
    tvRetweetCreatedAt.setTextColor(quote);
    tvRetweetSource.setTextColor(quote);
    ivLocation.setImageDrawable(iconLocation);
    tvLocation.setTextColor(quote);
    tvCreatedAt.setTextColor(quote);
    tvSource.setTextColor(quote);       
    
    int emphasize = theme.getColor("emphasize");
    tvRetweetCount.setTextColor(emphasize);
    tvCommentCount.setTextColor(emphasize);
    ivLineSeperator.setBackgroundDrawable(theme.getDrawable("line_comment_of_status_normal"));
    
    //工具条
    LinearLayout llToolbar = (LinearLayout)findViewById(R.id.llToolbar);
    Button btnComment = (Button)findViewById(R.id.btnComment);
    Button btnRetweet = (Button)findViewById(R.id.btnRetweet);
    Button btnFavorite = (Button)findViewById(R.id.btnFavorite);
    Button btnShare = (Button)findViewById(R.id.btnShare);
    Button btnMore = (Button)findViewById(R.id.btnMore);
    llToolbar.setBackgroundDrawable(theme.getDrawable("bg_toolbar"));
    btnComment.setBackgroundDrawable(theme.getDrawable("selector_toolbar_comment"));
    btnRetweet.setBackgroundDrawable(theme.getDrawable("selector_toolbar_retweet"));
    btnFavorite.setBackgroundDrawable(theme.getDrawable("selector_toolbar_favorite_add"));
    btnShare.setBackgroundDrawable(theme.getDrawable("selector_toolbar_share"));
    btnMore.setBackgroundDrawable(theme.getDrawable("selector_toolbar_more"));
    
	lvCommentsOfStatus = (ListView) this.findViewById(R.id.lvCommentsOfStatus);
	ThemeUtil.setListViewStyle(lvCommentsOfStatus);
	lvCommentsOfStatus.addHeaderView(headerView);
    setBack2Top(lvCommentsOfStatus);
    
    //注册上下文菜单
    View statusView = this.findViewById(R.id.llStatus);
    statusContextMenuListener = new MicroBlogStatusContextMenuListener(status);
    statusView.setOnCreateContextMenuListener(statusContextMenuListener);

    autoLoadMoreListener = new AutoLoadMoreListener();
}
 
Example 16
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 17
Source File: ImageViewer4GifActivity.java    From YiBo with Apache License 2.0 4 votes vote down vote up
private void initComponent() {
	LinearLayout llHeaderBase = (LinearLayout)findViewById(R.id.llHeaderBase);
	LinearLayout llToolbar = (LinearLayout)findViewById(R.id.llToolbar);
	ivRotateLeft = (ImageView) findViewById(R.id.ivRotateLeft);
	ivRotateRight = (ImageView) findViewById(R.id.ivRotateRight);
	ivZoomIn = (ImageView) findViewById(R.id.ivZoomIn);
	ivZoomOut = (ImageView) findViewById(R.id.ivZoomOut);
	
	ThemeUtil.setSecondaryImageHeader(llHeaderBase);
	llToolbar.setBackgroundDrawable(theme.getDrawable("bg_toolbar"));
	int padding8 = theme.dip2px(8);
	llToolbar.setPadding(padding8, padding8, padding8, padding8);
	ivRotateLeft.setBackgroundDrawable(theme.getDrawable("selector_btn_image_rotate_left"));
	ivRotateRight.setBackgroundDrawable(theme.getDrawable("selector_btn_image_rotate_right"));
	ivZoomIn.setBackgroundDrawable(theme.getDrawable("selector_btn_image_zoom_in"));
	ivZoomOut.setBackgroundDrawable(theme.getDrawable("selector_btn_image_zoom_out"));
	
	TextView tvTitle = (TextView) this.findViewById(R.id.tvTitle);
	tvTitle.setText(R.string.title_image_viewer);

	btnOperate = (Button) findViewById(R.id.btnOperate);

	ivImageViewer = (ImageViewTouchBase) findViewById(R.id.ivImageViewer);
	ivImageViewer.setRecycler(new ImageViewTouchBase.Recycler() {
		@Override
		public void recycle(Bitmap b) {
			if (!(b == null || b.isRecycled())) {
				if (Logger.isDebug()) {
					Log.d(TAG, "Recycle Bitmap : " + b);
				}
				b.recycle();
			}
		}
	});

	ivImageViewer.setOnClickListener(new View.OnClickListener() {
		@Override
		public void onClick(View v) {
			if (mode == Mode.View) {
				updateView();
			}
		}
	});
}
 
Example 18
Source File: EditRetweetActivity.java    From YiBo with Apache License 2.0 4 votes vote down vote up
private void initComponents() {
	LinearLayout llHeaderBase = (LinearLayout)findViewById(R.id.llHeaderBase);
	LinearLayout llContentPanel = (LinearLayout)findViewById(R.id.llContentPanel);
	LinearLayout llEditText = (LinearLayout)findViewById(R.id.llEditText);
	MultiAutoCompleteTextView etText  = (MultiAutoCompleteTextView)findViewById(R.id.etText);
	Button btnEmotion = (Button)this.findViewById(R.id.btnEmotion);
	Button btnMention = (Button)this.findViewById(R.id.btnMention);
	Button btnTopic = (Button)this.findViewById(R.id.btnTopic);
	Button btnTextCount = (Button)this.findViewById(R.id.btnTextCount);
	cbComment = (CheckBox) this.findViewById(R.id.cbComment);
	cbCommentToOrigin = (CheckBox)this.findViewById(R.id.cbCommentToOrigin);
	tvText = (TextView)this.findViewById(R.id.tvText);
	
	ThemeUtil.setSecondaryHeader(llHeaderBase);
	ThemeUtil.setContentBackground(llContentPanel);
	int padding6 = theme.dip2px(6);
	int padding8 = theme.dip2px(8);
	llContentPanel.setPadding(padding6, padding8, padding6, 0);
	llEditText.setBackgroundDrawable(theme.getDrawable("bg_input_frame_normal"));
	etText.setTextColor(theme.getColor("content"));
	btnEmotion.setBackgroundDrawable(theme.getDrawable("selector_btn_emotion"));
	btnMention.setBackgroundDrawable(theme.getDrawable("selector_btn_mention"));
	btnTopic.setBackgroundDrawable(theme.getDrawable("selector_btn_topic"));
	btnTextCount.setBackgroundDrawable(theme.getDrawable("selector_btn_text_count"));
	btnTextCount.setPadding(padding6, 0, theme.dip2px(20), 0);
	btnTextCount.setTextColor(theme.getColor("status_capability"));
	cbComment.setButtonDrawable(theme.getDrawable("selector_checkbox"));
	cbComment.setTextColor(theme.getColor("content"));
	cbCommentToOrigin.setButtonDrawable(theme.getDrawable("selector_checkbox"));
	cbCommentToOrigin.setTextColor(theme.getColor("content"));
	tvText.setTextColor(theme.getColor("quote"));
	
	TextView tvTitle = (TextView)this.findViewById(R.id.tvTitle);
	tvTitle.setText(R.string.title_retweet);
        
	MicroBlogTextWatcher textWatcher = new MicroBlogTextWatcher(this); 
	etText.addTextChangedListener(textWatcher);
	etText.setHint(R.string.hint_retweet);
	etText.requestFocus();
	etText.setAdapter(new UserSuggestAdapter(this));
	etText.setTokenizer(new EditMicroBlogTokenizer());
	
	retweetedStatus = status;
	if (status.getServiceProvider() != ServiceProvider.Sohu) {
		if (status.getServiceProvider() == ServiceProvider.Fanfou
			|| status.getRetweetedStatus() != null) {
			etText.setText(
				String.format(
					FeaturePatternUtils.getRetweetFormat(status.getServiceProvider()),
					FeaturePatternUtils.getRetweetSeparator(status.getServiceProvider()),
					status.getUser().getMentionName(),
					status.getText()
				)
			);
		}
		if (!(status.getServiceProvider() == ServiceProvider.Fanfou
			|| status.getRetweetedStatus() == null)) {
			retweetedStatus = status.getRetweetedStatus();
		}
		etText.setSelection(0);
	}

	int length = StringUtil.getLengthByByte(etText.getText().toString());
       int leavings = (int) Math.floor((double) (Constants.STATUS_TEXT_MAX_LENGTH * 2 - length) / 2);
       btnTextCount.setText((leavings < 0 ? "-" : "") + Math.abs(leavings));

	String lableComment = this.getString(R.string.label_retweet_with_comment, 
		status.getUser().getScreenName());
	cbComment.setText(lableComment);

	if (isComment2OriginVisible()) {
		String lableCommentToOrigin = this.getString(
			R.string.label_retweet_with_comment_to_origin,
			retweetedStatus.getUser().getScreenName());
		cbCommentToOrigin.setText(lableCommentToOrigin);
		cbCommentToOrigin.setVisibility(View.VISIBLE);
	}

	String promptText = retweetedStatus.getUser().getMentionTitleName()
		+ ":" + retweetedStatus.getText();
    tvText.setText(promptText);
}
 
Example 19
Source File: PickerBottomLayout.java    From Telegram-FOSS with GNU General Public License v2.0 4 votes vote down vote up
public PickerBottomLayout(Context context, boolean darkTheme) {
    super(context);

    setBackgroundColor(Theme.getColor(darkTheme ? Theme.key_dialogBackground : Theme.key_windowBackgroundWhite));

    cancelButton = new TextView(context);
    cancelButton.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 14);
    cancelButton.setTextColor(Theme.getColor(Theme.key_picker_enabledButton));
    cancelButton.setGravity(Gravity.CENTER);
    cancelButton.setBackgroundDrawable(Theme.createSelectorDrawable(0x0f000000, 0));
    cancelButton.setPadding(AndroidUtilities.dp(33), 0, AndroidUtilities.dp(33), 0);
    cancelButton.setText(LocaleController.getString("Cancel", R.string.Cancel).toUpperCase());
    cancelButton.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf"));
    addView(cancelButton, LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT, LayoutHelper.MATCH_PARENT, Gravity.TOP | Gravity.LEFT));

    doneButton = new LinearLayout(context);
    doneButton.setOrientation(LinearLayout.HORIZONTAL);
    doneButton.setBackgroundDrawable(Theme.createSelectorDrawable(0x0f000000, 0));
    doneButton.setPadding(AndroidUtilities.dp(33), 0, AndroidUtilities.dp(33), 0);
    addView(doneButton, LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT, LayoutHelper.MATCH_PARENT, Gravity.TOP | Gravity.RIGHT));

    doneButtonBadgeTextView = new TextView(context);
    doneButtonBadgeTextView.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf"));
    doneButtonBadgeTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 13);
    doneButtonBadgeTextView.setTextColor(Theme.getColor(Theme.key_picker_badgeText));
    doneButtonBadgeTextView.setGravity(Gravity.CENTER);
    Drawable drawable = Theme.createRoundRectDrawable(AndroidUtilities.dp(11), Theme.getColor(Theme.key_picker_badge));
    doneButtonBadgeTextView.setBackgroundDrawable(drawable);
    doneButtonBadgeTextView.setMinWidth(AndroidUtilities.dp(23));
    doneButtonBadgeTextView.setPadding(AndroidUtilities.dp(8), 0, AndroidUtilities.dp(8), AndroidUtilities.dp(1));
    doneButton.addView(doneButtonBadgeTextView, LayoutHelper.createLinear(LayoutHelper.WRAP_CONTENT, 23, Gravity.CENTER_VERTICAL, 0, 0, 10, 0));

    doneButtonTextView = new TextView(context);
    doneButtonTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 14);
    doneButtonTextView.setTextColor(Theme.getColor(Theme.key_picker_enabledButton));
    doneButtonTextView.setGravity(Gravity.CENTER);
    doneButtonTextView.setCompoundDrawablePadding(AndroidUtilities.dp(8));
    doneButtonTextView.setText(LocaleController.getString("Send", R.string.Send).toUpperCase());
    doneButtonTextView.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf"));
    doneButton.addView(doneButtonTextView, LayoutHelper.createLinear(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, Gravity.CENTER_VERTICAL));
}
 
Example 20
Source File: PickerBottomLayout.java    From TelePlus-Android with GNU General Public License v2.0 4 votes vote down vote up
public PickerBottomLayout(Context context, boolean darkTheme) {
    super(context);
    isDarkTheme = darkTheme;

    setBackgroundColor(isDarkTheme ? 0xff1a1a1a : Theme.getColor(Theme.key_windowBackgroundWhite));

    cancelButton = new TextView(context);
    cancelButton.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 14);
    cancelButton.setTextColor(isDarkTheme ? 0xffffffff : Theme.getColor(Theme.key_picker_enabledButton));
    cancelButton.setGravity(Gravity.CENTER);
    cancelButton.setBackgroundDrawable(Theme.createSelectorDrawable(isDarkTheme ? Theme.ACTION_BAR_PICKER_SELECTOR_COLOR : Theme.ACTION_BAR_AUDIO_SELECTOR_COLOR, 0));
    cancelButton.setPadding(AndroidUtilities.dp(29), 0, AndroidUtilities.dp(29), 0);
    cancelButton.setText(LocaleController.getString("Cancel", R.string.Cancel).toUpperCase());
    cancelButton.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf"));
    addView(cancelButton, LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT, LayoutHelper.MATCH_PARENT, Gravity.TOP | Gravity.LEFT));

    doneButton = new LinearLayout(context);
    doneButton.setOrientation(LinearLayout.HORIZONTAL);
    doneButton.setBackgroundDrawable(Theme.createSelectorDrawable(isDarkTheme ? Theme.ACTION_BAR_PICKER_SELECTOR_COLOR : Theme.ACTION_BAR_AUDIO_SELECTOR_COLOR, 0));
    doneButton.setPadding(AndroidUtilities.dp(29), 0, AndroidUtilities.dp(29), 0);
    addView(doneButton, LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT, LayoutHelper.MATCH_PARENT, Gravity.TOP | Gravity.RIGHT));

    doneButtonBadgeTextView = new TextView(context);
    doneButtonBadgeTextView.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf"));
    doneButtonBadgeTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 13);
    doneButtonBadgeTextView.setTextColor(isDarkTheme ? 0xffffffff : Theme.getColor(Theme.key_picker_badgeText));
    doneButtonBadgeTextView.setGravity(Gravity.CENTER);
    Drawable drawable;
    if (isDarkTheme) {
        drawable = Theme.createRoundRectDrawable(AndroidUtilities.dp(11), 0xff66bffa);
    } else {
        drawable = Theme.createRoundRectDrawable(AndroidUtilities.dp(11), Theme.getColor(Theme.key_picker_badge));
    }
    doneButtonBadgeTextView.setBackgroundDrawable(drawable);
    doneButtonBadgeTextView.setMinWidth(AndroidUtilities.dp(23));
    doneButtonBadgeTextView.setPadding(AndroidUtilities.dp(8), 0, AndroidUtilities.dp(8), AndroidUtilities.dp(1));
    doneButton.addView(doneButtonBadgeTextView, LayoutHelper.createLinear(LayoutHelper.WRAP_CONTENT, 23, Gravity.CENTER_VERTICAL, 0, 0, 10, 0));

    doneButtonTextView = new TextView(context);
    doneButtonTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 14);
    doneButtonTextView.setTextColor(isDarkTheme ? 0xffffffff : Theme.getColor(Theme.key_picker_enabledButton));
    doneButtonTextView.setGravity(Gravity.CENTER);
    doneButtonTextView.setCompoundDrawablePadding(AndroidUtilities.dp(8));
    doneButtonTextView.setText(LocaleController.getString("Send", R.string.Send).toUpperCase());
    doneButtonTextView.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf"));
    doneButton.addView(doneButtonTextView, LayoutHelper.createLinear(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, Gravity.CENTER_VERTICAL));
}