第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機(jī)立即綁定

只有右邊的button能顯示,求大大指導(dǎo)

引包略

public?class?Topbar?extends?RelativeLayout?{
/*
*?聲明控件
*/
private?Button?leftButton,?rightButton;
private?TextView?tvTitle;

/*
*?控件屬性lefttext
*/
private?int?leftTextColor;
private?Drawable?leftBackground;
private?String?leftText;

/*
*?控件屬性righttext
*/
private?int?rightTextColor;
private?Drawable?rightBackground;
private?String?rightText;

/*
*?控件屬性title
*/
private?Drawable?titleBackground;
private?int?titleTextColor;
private?float?titleTextSize;
private?String?title;

private?LayoutParams?leftParams,rightParams,titleParams;

@TargetApi(Build.VERSION_CODES.JELLY_BEAN)
public?Topbar(Context?context,?AttributeSet?attrs)?{
super(context,?attrs);

TypedArray?ta?=?context.obtainStyledAttributes(attrs,R.styleable.Topbar);

rightTextColor?=?ta.getColor(R.styleable.Topbar_rightTextColor,0);
rightBackground?=?ta.getDrawable(R.styleable.Topbar_rightBackground);
rightText?=?ta.getString(R.styleable.Topbar_rightText);

leftBackground?=?ta.getDrawable(R.styleable.Topbar_leftBackground);
leftText?=?ta.getString(R.styleable.Topbar_leftText);
leftTextColor?=?ta.getColor(R.styleable.Topbar_leftBackground,?0);

titleTextColor?=?ta.getColor(R.styleable.Topbar_mtitleTextColor,?0);
titleTextSize?=?ta.getDimension(R.styleable.Topbar_mtitleTextSize,?0);
title?=?ta.getString(R.styleable.Topbar_mtitle);
titleBackground?=?ta.getDrawable(R.styleable.Topbar_mtitleBackground);

ta.recycle();

leftButton?=?new?Button(context);
rightButton?=?new?Button(context);
tvTitle?=?new?TextView(context);

leftButton.setTextColor(leftTextColor);
leftButton.setBackground(leftBackground);
leftButton.setText(leftText);

rightButton.setTextColor(rightTextColor);
rightButton.setBackground(rightBackground);
rightButton.setText(rightText);

tvTitle.setText(title);
tvTitle.setTextSize(titleTextSize);
tvTitle.setTextColor(titleTextColor);
tvTitle.setGravity(Gravity.CENTER);

setBackgroundColor(0XFF81c7d4);

leftParams?=?new?LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT,LayoutParams.WRAP_CONTENT);
leftParams.addRule(RelativeLayout.ALIGN_PARENT_LEFT,?TRUE);

addView(leftButton,?leftParams);

rightParams?=?new?LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT,LayoutParams.WRAP_CONTENT);
rightParams.addRule(RelativeLayout.ALIGN_PARENT_RIGHT,?TRUE);

addView(rightButton,?rightParams);

titleParams?=?new?LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT,LayoutParams.WRAP_CONTENT);
titleParams.addRule(RelativeLayout.CENTER_IN_PARENT,?TRUE);

addView(tvTitle,?titleParams);
}

}


正在回答

1 回答

是不是沒有在布局里面聲明出來?

0 回復(fù) 有任何疑惑可以回復(fù)我~

舉報

0/150
提交
取消
Android UI模板設(shè)計
  • 參與學(xué)習(xí)       76030    人
  • 解答問題       233    個

快來學(xué)習(xí)如何在Android中自定義View,本次課程一定會讓你獲益匪淺

進(jìn)入課程

只有右邊的button能顯示,求大大指導(dǎo)

我要回答 關(guān)注問題
微信客服

購課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學(xué)習(xí)伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號