2017-12-14 19 views
1

나는 사용자 정의 글꼴을 부여한 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

이 설정 글꼴이 정렬 텍스트를 되돌리려 하는가를 적용하는 방법입니다

public class DiagAdapter extends RecyclerView.Adapter<DiagAdapter.ViewHolder> { private Context mContext; ArrayList<JsonObject> diagItem = new ArrayList<>(); public Typeface tf; 

dapter ? – ADM

+0

예. 하지만 문제는 어떻게 적용 할 수 있습니까? – Raphael

+0

이 https://stackoverflow.com/questions/1292575/android-textview-justify-text를 확인하십시오. 도움이 될 수 있습니다. –

답변

1

드디어 해결 방법이 있습니다. 나는 xml에 대한 정의를 적용하고 액티비티, 특히 어댑터에서 사용자 정의 글꼴을 설정했다. 는 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" /> 

이 컨텍스트

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);