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

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

android studio報錯。。Exception raised during rendering: Can't make a decor toolbar out of ActionBar(我的文件叫ActionBar)

package?com.example.demo.ui;

import?android.content.Context;
import?android.content.res.TypedArray;
import?android.graphics.drawable.Drawable;
import?android.util.AttributeSet;
import?android.view.Gravity;
import?android.widget.Button;
import?android.widget.RelativeLayout;
import?android.widget.TextView;

import?com.example.demo.R;

/**
?*?Created?by?xiaoqing?on?2015/7/8.
?*/
public?class?ActionBar?extends?RelativeLayout
{

????private?Button?leftButton,?rightButton;
????private?TextView?titleTextView;

????private?String?titleText;
????private?int?titleTextColor;
????private?float?titleTextSize;

????private?String?leftText;
????private?int?leftTextColor;
????private?Drawable?leftBackground;

????private?String?rightText;
????private?int?rightTextColor;
????private?Drawable?rightBackground;

????private?LayoutParams?leftParams,?rightParams,?titleParams;

????public?ActionBar(Context?context,?AttributeSet?attrs)
????{
????????super(context,?attrs);
????????TypedArray?ta?=?context.obtainStyledAttributes(attrs,?R.styleable.ActionBar);
????????leftText?=?ta.getString(R.styleable.ActionBar_leftText);
????????leftTextColor?=?ta.getColor(R.styleable.ActionBar_leftTextColor,?0);
????????leftBackground?=?ta.getDrawable(R.styleable.ActionBar_leftBackground);

????????rightText?=?ta.getString(R.styleable.ActionBar_rightText);
????????rightTextColor?=?ta.getColor(R.styleable.ActionBar_rightTextColor,?0);
????????rightBackground?=?ta.getDrawable(R.styleable.ActionBar_rightBackground);

????????titleText?=?ta.getString(R.styleable.ActionBar_titleText);
????????titleTextColor?=?ta.getColor(R.styleable.ActionBar_titleTextColor,?0);
????????titleTextSize?=?ta.getDimension(R.styleable.ActionBar_titleTextSize,?0);
????????ta.recycle();

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

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

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

????????titleTextView.setText(titleText);
????????titleTextView.setTextColor(titleTextColor);
????????titleTextView.setTextSize(titleTextSize);
????????titleTextView.setGravity(Gravity.CENTER);

????????setBackgroundColor(0xffff0000);

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

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

????????titleParams?=?new?LayoutParams(LayoutParams.WRAP_CONTENT,?LayoutParams.MATCH_PARENT);
????????titleParams.addRule(RelativeLayout.CENTER_IN_PARENT,?TRUE);
????????addView(titleTextView,?titleParams);
????}
}


正在回答

2 回答

設(shè)置style 的theme 為 NoActionBar試試

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

ViewGroup.LayoutParams.WRAP_CONTENT

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

舉報

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

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

進(jìn)入課程

android studio報錯。。Exception raised during rendering: Can't make a decor toolbar out of ActionBar(我的文件叫ActionBar)

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

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

幫助反饋 APP下載

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

公眾號

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