java - Android Title overlay's actionbar content -


i have application uses localisation , in of languages, title long size of screen. want scale title if doesn't fit correctly in space has smaller font size. use custom xml file title bar cannot figure out how scale font size depending on if fits or not. looking this, seems need lot of code quite small feature, can me resolve please! custom title:

<?xml version="1.0" encoding="utf-8"?> <relativelayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/title_bar" android:layout_width="match_parent" android:layout_height="wrap_content" android:background="@drawable/title_gradient" android:orientation="vertical" android:tag="title" >  <textview     android:id="@+id/title_text"     android:layout_width="wrap_content"     android:layout_height="wrap_content"     android:layout_centerinparent="true"     android:gravity="center"     android:paddingbottom="3dp"     android:text="@string/hearing_test"     android:textappearance="?android:attr/textappearancelarge"     android:textcolor="@color/solid_white"     android:textstyle="bold" />  <imagebutton     android:id="@+id/info_button"     android:layout_width="wrap_content"     android:layout_height="wrap_content"     android:layout_alignparentright="true"     android:layout_centervertical="true"     android:background="#0000"     android:padding="10dp"     android:onclick="infoview"     android:src="@drawable/info"     android:visibility="gone" > </imagebutton>  </relativelayout> 

the issue i've got text goes behind image button, goes onto 2 line user can see half of second line. if show me example, of send me link somewhere can help, brilliant. thanks

edit:

just add this, on newer phones such nexus 5, menu in top right corner , i've read, cannot find width of button, i'm bit stuck how can go finding width of in custom title bar!

you can scale textview text size according device screen , text length [note: if text long not readable. use length limit , show ... after it.], never mind, way is.

calculate device display size , find out scale factor, apply following code resize textview text size.

float size = textview.gettextsize();                 float factor = scalefactor;                 float product = size*factor;                 textview.settextsize(typedvalue.complex_unit_px, product);                 size = textview.gettextsize(); 

hope out.


Comments

Popular posts from this blog

java - Intellij Synchronizing output directories .. -

git - Initial Commit: "fatal: could not create leading directories of ..." -