2016-07-14 2 views
2

멀티 스크린을 지원하는 어플리케이션을 개발 중입니다. 장치 크기에 따라 레이아웃을 모두 완료했지만 동일한 작업 표시 줄/도구 모음 크기를 늘릴 수는 없습니다. 그 10inch 타블렛에서 작은 찾고. 툴바 텍스트의 크기를 어떻게 늘릴 수 있습니까?글자 크기 및 글자 스타일 글타래 (쓰레드) :

내 스타일 XML은 다음과

<resources> 

<!-- 
    Base application theme, dependent on API level. This theme is replaced 
    by AppBaseTheme from res/values-vXX/styles.xml on newer devices. 
--> 
<style name="AppBaseTheme" parent="android:Theme.Light"> 

</style> 


<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar"> 
    <!-- Customize your theme here. --> 
    <item name="colorPrimary">@color/colorPrimary</item> 
    <item name="colorPrimaryDark">@color/colorPrimaryDark</item> 
    <item name="colorAccent">@color/colorAccent</item> 
</style> 

<style name="AppTheme.NoActionBar"> 
    <item name="windowActionBar">false</item> 
    <item name="windowNoTitle">true</item> 
</style> 
<style name="AppTheme.FullScreen" parent="noActionBar"> 
<item name="android:windowFullscreen">true</item> 
</style> 
<style name="noActionBar" parent="Theme.AppCompat.NoActionBar"> 
    <item name="colorPrimary">@color/colorPrimary</item> 
    <item name="colorPrimaryDark">@color/colorPrimaryDark</item> 
    <item name="colorAccent">@color/colorAccent</item> 
</style> 
<style name="OptionDialog" parent="Theme.AppCompat.Dialog.Alert"> 

    <item name="colorAccent">#C5CAE9</item> 
    <item name="android:background">#3F51B5</item> 
    <item name="android:textColor">?android:attr/textColorPrimaryInverseDisableOnly</item> 
</style> 


<style name="AppTheme.AppBarOverlay" parent="ThemeOverlay.AppCompat.Dark.ActionBar" /> 

<style name="AppTheme.PopupOverlay" parent="ThemeOverlay.AppCompat.Light" /> 

<style name="SelectableItemTheme"> 
    <item name="colorControlHighlight">#888888</item> 
</style> 

<style name="SelectableItemBackground"> 
    <item name="android:theme">@style/SelectableItemTheme</item> 
    <item name="android:background">?attr/selectableItemBackground</item> 
</style> 


<style name="HomeTabTextStyle" 
    parent="TextAppearance.Design.Tab"> 
    <item name="android:textSize">35sp</item> 
    <item name="android:textStyle">bold</item> 
    </style> 

<!-- Action Bar Style --> 

같다 및 도구 모음을 포함하여 내 레이아웃 XML은

<android.support.design.widget.AppBarLayout 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:theme="@style/AppTheme.AppBarOverlay"> 

    <android.support.v7.widget.Toolbar 
     android:id="@+id/toolbar" 
     android:layout_width="match_parent" 
     android:layout_height="110dp" 
     android:background="?attr/colorPrimary" 
     app:popupTheme="@style/AppTheme.PopupOverlay" /> 

    <android.support.design.widget.TabLayout 
     android:id="@+id/tabs" 
     app:tabTextAppearance="@style/HomeTabTextStyle" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" /> 


</android.support.design.widget.AppBarLayout> 

내 자바 코드처럼 아래처럼 아래

setContentView(R.layout.activity_home); 
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); 
    setSupportActionBar(toolbar); 

    setTitle("My App Name"); 

답변

4

툴바 다른 레이아웃과 같습니다. 즉, 다음과 같이 요소를 추가 할 수 있습니다.

 <android.support.v7.widget.Toolbar 
     android:id="@+id/toolbar" 
     android:layout_width="match_parent" 
     android:layout_height="?attr/actionBarSize" 
     android:background="?attr/colorPrimary" 
     app:popupTheme="@style/AppTheme.PopupOverlay"> 

     <TextView 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:textSize="25sp" 
      android:textColor="@color/colorText" 
      android:gravity="center|center_horizontal" 
      android:text="@string/title_activity_my_activity"/> 

    </android.support.v7.widget.Toolbar> 

이렇게하면 툴바 제목의 제목 크기가 변경됩니다. 당신이 원하는대로.

여러분의 목표 달성에 도움이되기를 바랍니다. 행운을 빕니다.

UPDATE

수동,이 같은 텍스트 뷰의 ID를 설정할 수 있습니다 활동 제목을 설정하려면 :

<TextView 
     android:id="@+id/title_text" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:textSize="25sp" 
     android:textColor="@color/colorText" 
     android:gravity="center|center_horizontal" 
     android:text="@string/title_activity_my_activity"/> 

그런 다음 평소처럼,

TextView title = (TextView) toolbar.findViewById(R.id.title_text); 
title.setText("New Title"); 

이 도움이 되었기를 바랍니다.

+0

안녕하세요! 제발 내 자바 코드를 봐 ... 내가 어떻게 귀하의 답변 당 그것을 변경할 수 있습니까? 왜냐하면 나는 textview ...를 사용하지 않았기 때문입니다. 감사합니다. –

+0

기본적으로이 툴바에 TextView를 추가 할 수 있으며, 각기 다른 크기의 디바이스에 대해 텍스트 크기가 다릅니다. – Eenvincible

+0

예 ... 이해하고 도와 주셔서 고맙지 만 실제로이 자바 스크립트 코드를 사용하여이 텍스트 뷰를 변경해야합니까? 제 질문에 추가 한 자바 코드를 확인하십시오 ... 다시 감사 드리며 제 지식이 부족해서 죄송합니다. ( –