我正试图在一个按钮中使用具有不同字体的两个TextView自定义按钮。为此,我扩展了Button并在构造函数中编写了以下代码:
在布局文件 custom_button 中,我放置了两个具有不同字体和文本的 TextView,并将其包裹在一个名为 custom_button_view 的 LinearLayout 中,但是我得到的结果是一个没有文本的空按钮。
有任何想法,谢谢。
LayoutInflater layoutInflater = (LayoutInflater) context
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View layout = layoutInflater.inflate(R.layout.custom_button,
(ViewGroup) findViewById(R.id.custom_button_view));
TextView firstTextView = (TextView) layout
.findViewById(R.id.firstTextView);
TextView secondTextView = (TextView) layout
.findViewById(R.id.secondTextView);
在布局文件 custom_button 中,我放置了两个具有不同字体和文本的 TextView,并将其包裹在一个名为 custom_button_view 的 LinearLayout 中,但是我得到的结果是一个没有文本的空按钮。
有任何想法,谢谢。