Custom Button with two TextView

前端 未结 3 1635
攒了一身酷
攒了一身酷 2020-12-11 05:34

I\'m trying to Customize button with two TextView with different typeface within a single button. For that I just extended Button and with have written the following code in

3条回答
  •  盖世英雄少女心
    2020-12-11 06:10

    You can use Layout as a button by setting ur custom button style to layout and can add two textViews to it, in this way:

    
        
        
    
    

    and in Activity you can have this to set different typeface:

        Typeface font=Typeface.createFromAsset(getAssets(),"ARIALN.TTF") ;   
        Typeface font2=Typeface.createFromAsset(getAssets(), "COMPCTAN.TTF");
    
        TextView firstTextView = (TextView)findViewById(R.id.firstTextView);
        TextView secondTextView = (TextView)findViewById(R.id.secondTextView);
    
        firstTextView.setTypeface(font);
        secondTextView.setTypeface(font2);
    
        LinearLayout btnLayout=(LinearLayout) findViewById(R.id.customButtonLayout);
        btnLayout.setOnClickListener(this);
    

提交回复
热议问题