How can you implement a button where, for example, the main text on the left side would be large in bold, and a small description in one sentence below the main text on the right edge in semi-transparent letters?
- And how do you want? Dynamically? Is it static? Many different ways designed for different purposes! Please specify. - Marc Bale
|
1 answer
You can make LinerLayout add two TextView and arrange them as you like. And then just hang the listener when you click on it to do what you need.
xml:
<LinearLayout android:id="@+id/customButtonLayout" android:layout_height="wrap_content" style="@android:style/Widget.Button" android:layout_width="wrap_content"> <TextView android:text="First" android:id="@+id/firstTextView" android:layout_width="wrap_content" android:layout_height="wrap_content" android:textColor="#000"></TextView> <TextView android:textColor="#000" android:text="Second" android:layout_height="wrap_content" android:id="@+id/secondTextView" android:layout_width="wrap_content" android:layout_marginLeft="10dp"></TextView> </LinearLayout> code:
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); |