2017-10-09 15 views
1

나는 모든 레이아웃에서 반복되는 textview 및 edittext를 사용하므로 태그를 포함하여 반복을 사용하십시오.포함 레이아웃에 자식 글꼴을 설정할 수 없습니다

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    xmlns:tools="http://schemas.android.com/tools" 
    android:id="@+id/llCompany" 
    android:orientation="vertical" 
    tools:showIn="@layout/activity_verify"> 

    <TextView 
     android:id="@+id/txtCompanyName" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_gravity="center" 
     android:layout_marginTop="5dp" 
     android:text="@string/companyname" 
     android:textColor="@color/greyLight" /> 

    <EditText 
     android:id="@+id/edtCompanyName" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:gravity="center" 
     android:imeOptions="actionNext" 
     android:inputType="text" 
     android:maxLines="1" 
     android:textColor="@color/black" 
     android:textSize="16sp" 
     android:theme="@style/MyEditTextTheme" /> 

</LinearLayout> 

<ScrollView 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:layout_below="@+id/linearLayout2" 
    android:overScrollMode="never"> 

    <LinearLayout 
      android:id="@+id/llEmployee" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:orientation="vertical" 
      android:visibility="gone"> 

       <include 
        android:layout_width="match_parent" 
        android:layout_height="wrap_content" 
        android:id="@+id/llCompany" 
        layout="@layout/layout_company" />    
     </LinearLayout> 

     <LinearLayout 
      android:id="@+id/llContactor" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:orientation="vertical" 
      android:visibility="gone"> 

       <include 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" 
       android:id="@+id/llCompany" 
       layout="@layout/layout_company" />    
     </LinearLayout> 

     <LinearLayout 
      android:id="@+id/llManager" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:orientation="vertical" 
      android:visibility="gone"> 

       <include 
        android:layout_width="match_parent" 
        android:layout_height="wrap_content" 
        android:id="@+id/llCompany" 
        layout="@layout/layout_company" />    
     </LinearLayout> 
</ScrollView> 

layout_company.xml 지금 내 문제는 내가 내 레이아웃을 포함하는 텍스트 뷰에 서체를 설정할 수 없습니다 생각합니다.

내가이 링크를 시도 : findViewById not working for an include?

하지만 나를 위해 작동하지 그 .. 내가없는 무언가가있다. 자바 파일에서

:

LinearLayout view = (LinearLayout) findViewById(R.id.llCompany); 
txtCompanyName = (TextView)view.findViewById(R.id.txtCompanyName); 
edtCompanyName = (EditText) view.findViewById(R.id.edtCompanyName); 
txtCompanyName.setTypeface(Glob.avenir(context)); 
edtCompanyName.setTypeface(Glob.avenir(context)); 

나는 또한 ID (직접 접근)없이 함께했는데, 그 중 하나가 작동하지. 감사합니다. . 모두 포함을 위해

enter image description here

+0

전체 글꼴 또는 특정 레이아웃을 사용하고 싶습니까? – arcticwhite

+0

내가 원하는 것은 childview ..에 대한 액세스 권한을 갖는 것입니다 .. 서체에 관한 것뿐만 아니라 .. 이것은 단지 예입니다 .. –

+0

연락처 관리자의 첫 번째 레이아웃이 동일한 XML 파일에 있습니까? –

답변

0

동일한 ID를 사용하고 있습니다. 모든 포함에 대해 고유 한 ID를 제공하십시오.