大佬教程收集整理的这篇文章主要介绍了android – 按钮左右对齐的文本,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
[**Name** john] //Name is bold and black // john is smaller and let's say blue
this.button.setText(Html.fromHtml(styledText));
但它看起来不适用于alignment =“right”,text-allign:right或者甚至
浮动:正确的.
我还找到了另一种使用表格布局和表格行的解决方案,但我需要一个按钮来触发一些动作.我不希望文本的两个部分有两个按钮.
提前致谢.
<?xml version="1.0" encoding="utf-8"?> <SELEctor xmlns:android="http://scheR_572_11845@as.android.com/apk/res/android"> <item android:drawable="@drawable/button_bg_pressed" android:state_pressed="true"></item> <item android:drawable="@drawable/button_bg_normal"></item> </SELEctor>
第2步:使用两个TextView创建一个LinearLayout.
<LinearLayout android:id="@+id/myCustomButton" android:layout_width="wrap_content" android:layout_height="wrap_content" android:orientation="horizontal" android:BACkground="@drawable/button_SELEctor" > <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:gravity="left" android:textStyle="bold" android:textColor="@color/black" android:BACkground="@drawable/ai_contact_us" /> <TextView android:id="@+id/aiResetPwdButton" android:layout_width="wrap_content" android:layout_height="wrap_content" android:gravity="right" android:textColor="@color/blue"/> </LinearLayout>
第3步:在你的onCreate()
View buttonView = findViewById(R.id.myCustomButton); buttonView.setOnClickListener(new View.onClickListenet(){ @Override public void onClick(View view) { Toast.makeText(MainActivity.this,"Button Clicked",Toast.LENGTH_SHORT).show(); } });
以上是大佬教程为你收集整理的android – 按钮左右对齐的文本全部内容,希望文章能够帮你解决android – 按钮左右对齐的文本所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。