我有Textview
我给了自定义字体。我如何才能最好地将理由应用于同一Textview
。
这是我应用自定义字体的方式
<extension.ezyagric.com.android.Widgets.FiraTextView
android:id="@+id/body"
android:paddingTop="5dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="fill_vertical"
android:layout_below="@+id/thumbnail"
android:textColor="@color/black"
android:textSize="15sp" />
这是我试图用来证明Textview
的证据的图书馆,但我未能达到我想要的目标
<me.biubiubiu.justifytext.library.JustifyTextView
android:id="@+id/body"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingEnd="10dp"
android:paddingRight="10dp"
android:paddingLeft="10dp"
android:fontFamily="@assets/Roboto-Bold"
android:layout_below="@+id/thumbnail"
android:textColor="@color/black"
android:textSize="15sp" />
事实上,图书馆可以为Textview
辩护。但是,如何实现自定义字体和Textview
的合理性。任何帮助都非常欢迎。提前致谢
答案 0 :(得分:1)
我终于找到了解决方法。我在xml上应用了justication并从活动中设置了自定义字体,特别是适配器。 xml
<me.biubiubiu.justifytext.library.JustifyTextView
android:paddingTop="2dp"
android:textColor="@color/black"
android:id="@+id/control"
android:layout_gravity="fill"
android:layout_below="@+id/cntrl_header"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textSize="15sp" />
dapter
public class DiagAdapter extends RecyclerView.Adapter<DiagAdapter.ViewHolder> {
private Context mContext;
ArrayList<JsonObject> diagItem = new ArrayList<>();
public Typeface tf;
这是上下文
public DiagAdapter(Context context, ArrayList<JsonObject> diagItem) {
this.diagItem = diagItem;
this.mContext = context;
this.tf = Typeface.createFromAsset(context.getAssets(), "FiraSans-Light.ttf");
}
这就是我应用它的方式
viewHolder.cause.setText(sl.has("cause")?sl.get("cause").getAsString():"");
viewHolder.cause.setTypeface(tf);